⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 script_editor.js

📁 IBM RSA下的JSF开发示例
💻 JS
📖 第 1 页 / 共 5 页
字号:
				 xxx++;			}			/*var img = IBM_RTE_getDocument(editorName).body.getElementsByTagName("img");			var xxx=0;			while(img[xxx] != null){				if(img[xxx].getAttribute("odc") != "" && img[xxx].getAttribute("odc") != null){					img[xxx].setAttribute("src", img[xxx].getAttribute("odc"));					img[xxx].removeAttribute("odc");				}				xxx++;			}*/	   }		var hh = IBM_RTE_getDocument(editorName).body.innerHTML;	//		if(hh.match(/<xmp id=9669 contentEditable=false style=\"DISPLAY: inline\"><\/xmp>/i) != null)	//			hh = hh.replace(/<xmp id=9669 contentEditable=false style=\"DISPLAY: inline\"><\/xmp>/i, "");			hh = hh.replace(/&#[0-2]?[0-9];/g,"");			hh = hh.replace(/&#3[01];/g,"");			hh = stripControlCharacters(hh);			var html = IBM_RTE_getDocument(editorName).body.innerHTML;			var xhtml = html.replace(/\\/g,'\\\\');			//alert('The xhtml : ' + xhtml);			return xhtml;//			return hh;	}}function IBM_RTE_setEditorHTML(editorName, content) {if(IBM_RTE_getEditorMode(editorName) != 0){	var Text1 = new String(content);	Text1 = Text1.replace(/&#[0-2]?[0-9];/g,"");	Text1 = Text1.replace(/&#3[01];/g,"");	Text1 = stripControlCharacters(Text1);		if(IBM_RTE_isMozilla()){		var html = IBM_RTE_getDocument(editorName).createTextNode(Text1);		IBM_RTE_getDocument(editorName).body.innerHTML = "";		IBM_RTE_getDocument(editorName).body.appendChild(html);	}	else		IBM_RTE_getDocument(editorName).body.innerText = Text1;}else {	if (IBM_RTE_isMozilla()){		var Text1 = new String(content);		Text1 = Text1.replace(/&#[0-2]?[0-9];/g,"");		Text1 = Text1.replace(/&#3[01];/g,"");		Text1 = stripControlCharacters(Text1);			var str3    = "" + "<a .*?[^\/]>";		var re3     = new RegExp(str3.toString(),"gi");		var matches = Text1.match(re3);		var xx      = 0;		if(matches != null)			while(true){				if(matches[xx] == null) break;				var Smatch = matches[xx];				var str69  = "" + "href=\"'";				var re69   = new RegExp(str69.toString(),"i");				var str96  = "" + "href='\"";				var re96   = new RegExp(str96.toString(),"i");				if(re69.test(Smatch) == false && re96.test(Smatch) == false && isCustomTag(Smatch)==false){					var cmpts = matches[xx].match(/href=(["'])([^\1]*?)\1/i);					if(cmpts != null)					{						var quot  = cmpts[1];						var href  = cmpts[2];						temp = "href=\"" + href.replace(/\"/gi,"'") + "\" odc=\"" + href.replace(/\"/gi,"'") + "\" "; 							matches[xx] = matches[xx].replace(/href=(["'])([^\1]*?)\1/i, temp);						Text1 = Text1.replace(Smatch.toString(), matches[xx].toString()); 					}				}				xx++;			}			/*			var matches = Text1.match(/<img.*?src=(['"])[^\1]*?\1.*?[\/]?>/gi);			var xx      = 0;					if(matches != null)				while(true){					if(matches[xx] == null) break;					var Smatch = matches[xx];					var str69  = "" + "src=\"'";					var re69   = new RegExp(str69.toString(),"i");					var str96  = "" + "src='\"";					var re96   = new RegExp(str96.toString(),"i");					if(re69.test(Smatch) == false && re96.test(Smatch) == false && isCustomTag(Smatch)==false){						var cmpts = matches[xx].match(/src=(["'])([^\1]*?)\1/i);						if(cmpts != null){							var quot = cmpts[1];							var src  = cmpts[2];							temp = "src=\"" + src.replace(/\"/gi,"'") + "\" odc=\"" + src.replace(/\"/gi,"'") + "\" "; 								matches[xx] = matches[xx].replace(/src=(["'])([^\1]*?)\1/i, temp);							Text1 = Text1.replace(Smatch.toString(), matches[xx].toString()); 						}					}					xx++;				}*/	}else{		var Text1 = new String(content);		Text1 = Text1.replace(/&#[0-2]?[0-9];/g,"");		Text1 = Text1.replace(/&#3[01];/g,"");		Text1 = stripControlCharacters(Text1);		//		if(Text1.match(/<xmp id=9669 contentEditable=false style=\"DISPLAY: inline\"><\/xmp>/i) == null)//			Text1 = "<xmp id=9669 contentEditable=false style=\"DISPLAY: inline\"></xmp>" + Text1;		var str3    = "" + "<a .*?[^/]>";		var re3     = new RegExp(str3.toString(),"gi");		var matches = Text1.match(re3);		var xx      = 0;				if(matches != null)			while(true){				if(matches[xx] == null) break;								var Smatch = matches[xx];				var str69  = "" + "href=\"'";				var re69   = new RegExp(str69.toString(),"i");				var str96  = "" + "href='\"";				var re96   = new RegExp(str96.toString(),"i");				if(re69.test(Smatch) == false && re96.test(Smatch) == false && isCustomTag(Smatch)==false)				{									var cmpts = matches[xx].match(/href=(["'])([^\1]*?)\1/i);					if(cmpts != null)					{						var quot  = cmpts[1];						var href  = cmpts[2];						temp = "href=\"" + href.replace(/\"/gi,"'") + "\" odc=\"" + href.replace(/\"/gi,"'") + "\" "; 							matches[xx] = matches[xx].replace(/href=(["'])([^\1]*?)\1/i, temp);						Text1 = Text1.replace(Smatch.toString(), matches[xx].toString()); 					}				}				xx++;			}			/*		var matchesImg = Text1.match(/<img.*?src=(['"])[^\1]*?\1.*?[\/]?>/gi);		xx = 0;					if(matchesImg != null)			while(true)			{				if(matchesImg[xx] == null) break;				var Smatch = matchesImg[xx];				var str69  = "" + "src=\"'";				var re69   = new RegExp(str69.toString(),"i");					var str96  = "" + "src='\"";				var re96   = new RegExp(str96,"i");				if(re69.test(Smatch) == false && re96.test(Smatch) == false && isCustomTag(Smatch)==false)				{					var cmpts = matchesImg[xx].match(/src=(["'])([^\1]*?)\1/i);					if(cmpts != null)					{						var quot = cmpts[1];						var src  = cmpts[2];						temp = "src=\"" + src.replace(/\"/gi,"'") + "\" odc=\"" + src.replace(/\"/gi,"'") + "\" "; 							matchesImg[xx] = matchesImg[xx].replace(/src=(["'])([^\1]*?)\1/i, temp);						Text1 = Text1.replace(Smatch.toString(), matchesImg[xx].toString()); 					}				}				xx++;			}*/	}IBM_RTE_getDocument(editorName).body.innerHTML = Text1;	if (IBM_RTE_isMozilla()){		var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");		var xxx=0;		while(a[xxx] != null)		{			if(a[xxx].getAttribute("odc") != "" && a[xxx].getAttribute("odc") != null) 				a[xxx].setAttribute("href", a[xxx].getAttribute("odc"));			xxx++;		}		/*var b = IBM_RTE_getDocument(editorName).body.getElementsByTagName("IMG");		var xxx=0;		while(b[xxx] != null)		{			if(b[xxx].getAttribute("odc") != "" && b[xxx].getAttribute("odc") != null) 				b[xxx].setAttribute("src", b[xxx].getAttribute("odc"));			xxx++;		}*/	}	else{		var a = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");		var xxx=0;		while(a[xxx] != null){			if(a[xxx].odc != "" && a[xxx].odc != null) 				a[xxx].href = a[xxx].odc;			xxx++;		}		/*var b = IBM_RTE_getDocument(editorName).body.getElementsByTagName("IMG");		var xxx=0;		while(b[xxx] != null){			if(b[xxx].odc!= "" && b[xxx].odc != null) 				b[xxx].src = b[xxx].odc;			xxx++;		}*/	}}}function IBM_RTE_flipDocument(editorName) {	if(!IBM_RTE_isMozilla()){		if(isAccessible) 			this.opener.IBM_RTE_backup(editorName);		else			IBM_RTE_backup(editorName);	}    var origDir =  IBM_RTE_getDocument(editorName).body.dir;    if ((origDir.localeCompare('') == 0)||(origDir.localeCompare('ltr') == 0))        IBM_RTE_getDocument(editorName).body.dir = "rtl";    else if (origDir.localeCompare('rtl') == 0)        IBM_RTE_getDocument(editorName).body.dir = "ltr";    IBM_RTE_getWindow(editorName).focus();}function IBM_RTE_getSelectionRange(editorName){      var doc = IBM_RTE_getDocument(editorName);      var win = IBM_RTE_getWindow(editorName);	var ret = null; 	if(doc.selection)		ret = doc.selection.createRange();	else if (win.getSelection)	{		var sel = win.getSelection();		if(sel != null && sel.rangeCount > 0)			ret = sel.getRangeAt(0);	}	return ret;}// TODO: detect and clean up redundant DIR tags while preserving other tags.// Mozilla has no good way to insert a new node to subsume the selection content // other than using surroundContents(). SurroundContents() is not very tolerant in// the selection, such as if the Range partially selects a non-Text node, // surroundContents() raises an exception.// Using separate operations extractContents(), insertNode() will NOT help, it would// only make things worse, as when insertNode() throws exception, the range content // has been removed already. Using surroundContents(), when it throws exception, the // range content will remain unchanged.//// May need to find a way to mimic IE's behavior???function IBM_RTE_flipSelection(editorName, dir) {    // Get a selection range.    var rng = IBM_RTE_getSelectionRange(editorName);	if(!IBM_RTE_isMozilla()){		if(isAccessible) 			this.opener.IBM_RTE_backup(editorName);		else			IBM_RTE_backup(editorName);	}        if (IBM_RTE_isMozilla()) {        if (rng) {  		var arr = IBM_RTE_getDocument(editorName).body.getElementsByTagName('P');		var xx = 0;		while(arr[xx] != null)		{			var bodyRange = IBM_RTE_getDocument(editorName).createRange();			var inRange = false;			paraRange = bodyRange;			paraRange.setStartBefore(arr[xx]);			paraRange.setEndAfter(arr[xx]);			var START_TO_START = 0;			var END_TO_START = 3;			if(paraRange.compareBoundaryPoints(START_TO_START,rng) >= 0){				if(paraRange.compareBoundaryPoints(END_TO_START,rng) <= 0)					inRange = true;			}			else if(rng.compareBoundaryPoints(END_TO_START,paraRange) <= 0)				inRange = true;			if(inRange){				arr[xx].dir = dir;			}			xx++;		}		}    }else {        if (rng) {			var parent = rng.parentElement();			var arr = IBM_RTE_getDocument(editorName).body.getElementsByTagName('P');			var xx = 0;			var enteredInRange = false;			var paraRange;			while(arr[xx]!=null)			{				var inRange = false;				paraRange = IBM_RTE_getDocument(editorName).body.createTextRange();				paraRange.moveToElementText(arr[xx]);				try{					if(paraRange.compareEndPoints("StartToStart",rng) <= 0){						if(paraRange.compareEndPoints("EndToStart",rng) >= 0){							inRange = true;						}					}					else if(rng.compareEndPoints("EndToStart",paraRange) >= 0)						inRange = true;				}catch(e){}				if(inRange){					parent = arr[xx];					parent.dir = dir;					enteredInRange = true;				}				else if(enteredInRange)break;				xx++;			}		}	}    IBM_RTE_getWindow(editorName).focus();}function IBM_RTE_checkEvent(editorName) {   if (typeof checkEvent != 'undefined') {       checkEvent();    }    }// These three functions are actually used in dialogs to highlight // buttons when mouse is moved over. Use document instead of // IBM_RTE_getDocument() because dialogs are in their own windows.function setStyle(element, name, value) {        if (element.style && (element.style[name] != value) )            element.style[name] = value;}function IBM_RTE_btn_mouseover(id) {                var elmt = document.getElementById(id);        if (elmt) {            setStyle(elmt, 'color', '#0000FF');            setStyle(elmt, 'borderColor', '#0000FF');        }}function IBM_RTE_btn_mouseoout(id) {                var elmt = document.getElementById(id);        if (elmt) {            setStyle(elmt, 'color', '#405380');            setStyle(elmt, 'borderColor', '#405380');        }}function IBM_RTE_setATag(editorName) {        var aTags = IBM_RTE_getDocument(editorName).body.getElementsByTagName("A");        var len = aTags.length;        for (var i=0; i < len; i++) {            var aLink = aTags[i].href;            if (aLink.substring(0, 5) == "http:") {                aTags[i].target = "_blank";            }            else if (aLink.substring(0, 6) == "https:") {                aTags[i].target = "_blank";            }            else if (aLink.substring(0, 4) == "ftp:") {                aTags[i].target = "_blank";            }            else if (aLink.substring(0, 5) == "file:") {                aTags[i].target = "_blank";            }        }}// The following functions are for advanced table support.// Added in 5.1 release.//This is a utility function to return the current row where the cursor is.function IBM_RTE_getCurrentRow(editorName) {    var selRange = IBM_RTE_getSelectionRange(editorName);    var currentRow;    if (IBM_RTE_isMozilla()) {        currentRow = selRange.startContainer;        var strName = currentRow.nodeName;                 while(strName != "TR") {            currentRow = currentRow.parentNode;            if (currentRow == null) break;            strName = currentRow.nodeName;        }    }    else {        currentRow = selRange.parentElement();        var strName = currentRow.tagName;                while(strName != "TR") {            currentRow = currentRow.parentNode;            if (currentRow == null) break;            strName = currentRow.tagName;        }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -