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

📄 _editor.js

📁 具有的功能适合于网站的运营和管理
💻 JS
📖 第 1 页 / 共 2 页
字号:
		<option value="'+__lang('lishu')+'">'+__lang('lishu')+'</option> \		<option value="'+__lang('youyuan')+'">'+__lang('youyuan')+'</option> \		<option value="Arial">Arial</option> \		<option value="Arial Black">Arial Black</option> \		<option value="Arial Narrow">Arial Narrow</option> \		<option value="Brush Script	MT">Brush Script MT</option> \		<option value="Century Gothic">Century Gothic</option> \		<option value="Comic Sans MS">Comic Sans MS</option> \		<option value="Courier">Courier</option> \		<option value="Courier New">Courier New</option> \		<option value="MS Sans Serif">MS Sans Serif</option> \		<option value="Script">Script</option> \		<option value="System">System</option> \		<option value="Times New Roman">Times New Roman</option> \		<option value="Verdana">Verdana</option> \		<option value="Wide Latin">Wide Latin</option> \		<option value="Wingdings">Wingdings</option> \	</SELECT>';	//font size	tbm.innerHTML += '<SELECT onchange="applyCommand(\'fontsize\',this[this.selectedIndex].value);this.selectedIndex=0;editor.focus();"> \		<option selected>'+__lang('fontsize')+'</option> \		<option value="7">'+__lang('fontsize_1')+'</option> \		<option value="6">'+__lang('fontsize_2')+'</option> \		<option value="5">'+__lang('fontsize_3')+'</option> \		<option value="4">'+__lang('fontsize_4')+'</option> \		<option value="3">'+__lang('fontsize_5')+'</option> \		<option value="2">'+__lang('fontsize_6')+'</option> \		<option value="1">'+__lang('fontsize_7')+'</option> \	</SELECT>';	//other op	for (var i = 0; i < toolBars.length; ++i) {		tbm.innerHTML += '<img src="' + _toolBarIconPath + '/' + toolBars[i][2] + '.gif" onclick="' + toolBars[i][1] + '" border="0" alt="' + toolBars[i][0] + '" onmouseover="this.style.backgroundColor=\'#CCCCCC\';" onmouseout="this.style.backgroundColor=\'\';" align="absmiddle">';	}	tbm.innerHTML += '<span style="color:red;font-size:12px" id="__wordCount__"></span>';	textObj.parentElement.insertBefore(tbm, editObj);	_toolBar = tbm;	var tbm1 = document.createElement('span');	tbm1.style.width = textObj.style.width;	tbm1.style.display = 'none';	tbm1.id = '_toolbar1';	tbm1.innerHTML = '';	for (var i = 0; i < toolBars1.length; ++i) {		tbm1.innerHTML += '<img src="' + _toolBarIconPath + '/' + toolBars1[i][2] + '.gif" onclick="' + toolBars1[i][1] + '" border="0" alt="' + toolBars1[i][0] + '" onmouseover="this.style.backgroundColor=\'#CCCCCC\';" onmouseout="this.style.backgroundColor=\'\';" align="absmiddle">';	}	tbm1.innerHTML += '<span style="color:red;font-size:12px" id="__wordCount1__"></span>';	textObj.parentElement.insertBefore(tbm1, editObj);    _toolBar1 = tbm1;}//save select infovar sel,rng,selOK;function saveSelection(){	if (!textObj || !isIE5) {		return;	}	sel = editor.document.selection;	rng = sel.createRange();}function reselect(){	if (!textObj || !isIE5) {		return;	}	if (!sel || sel == null){		selOK = false;		return;	}	if (sel.type != "None") return;	try {		r = editor.document.body.createTextRange();		if ( r.inRange(rng) ){			selOK = true;			r.setEndPoint("StartToStart", rng);			r.setEndPoint("EndToEnd", rng);			r.select();		} else {			selOK = false;		}	}catch(e) {		rng.select();		selOK = true;	}}//normal actionfunction insertHTML(txt){	if (!textObj || !isIE5) {		return;	}	if ( !selOK  ){		r = editor.document.body.createTextRange();		r.move("word", 1);		r.collapse();		r.select();	}	if (!sel || sel == null){		return;	}	if ( sel.type == "Control" ) {		sel.createRange().item(0).outerHTML = txt;	} else {		rng = sel.createRange();		rng.pasteHTML(txt);		rng.select();	}}function HTMLEncode(text){	text = text.replace(/&/g, "&amp;") ;	text = text.replace(/"/g, "&quot;") ;	text = text.replace(/</g, "&lt;") ;	text = text.replace(/>/g, "&gt;") ;	text = text.replace(/'/g, "&#146;") ;	text = text.replace(/\ /g,"&nbsp;");	text = text.replace(/\n/g,"<br>");	text = text.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");	return text;}var _isEditAble = true;function recove() {	if (!textObj || !isIE5) {		return;	}	if (_isEditAble) {		save();		textObj.style.display = 'block';		_toolBar.style.display = 'none';		editObj.style.display = 'none';		_toolBar1.style.display = 'block';		_isEditAble = false;	}else {		load();		textObj.style.display = 'none';		editObj.style.display = 'block';		_toolBar.style.display = 'block';		_toolBar1.style.display = 'none';		_isEditAble = true;	}}//previewfunction doPreview() {	if (!textObj || !isIE5) {		return;	}	if (_isEditAble) {		save();	}else {		load();	}	var frm = document.createElement('form');	frm.action = _postAction;	frm.method = 'post';	frm.target = '_blank';	var txt = document.createElement('input');	txt.type = 'hidden';	txt.value = editor.document.body.innerHTML;	txt.name = 'desc';	frm.appendChild(txt);	frmObj.parentElement.appendChild(frm);	frm.submit();	frm.removeNode(frm);}function applyCommand(opt,what){	if (!textObj || !isIE5) {		return;	}	reselect();	editor.document.execCommand(opt,"",what);}function save() {	if (!textObj || !isIE5) {		return;	}	if (_isEditAble && textObj && editor && editor.document) {		textObj.value = editor.document.body.innerHTML;		if(textObj.value!=oldvalue) {			try {				document.mainform.state.value=1;			}catch (e) {			}		}else{			try {				document.mainform.state.value=0;			}catch (e) {			}		}	}}function load() {	if (!textObj || !isIE5 || _isEditAble) {		return;	}	try {		editor.document.body.innerHTML = textObj.value;	}catch (e) {	}}function getClientXY(obj, top) {	distance = 0;	for ( i=0; i<10; i++){		if ( top ){			distance += obj.offsetTop+obj.clientTop;		} else {			distance += obj.offsetLeft+obj.clientLeft;		}		obj = obj.offsetParent;		if ( obj == document.body ) break;	}	return distance;}//calc countvar _calcCountTimer;function calcWordCount() {	if (!textObj || !isIE5) {		return;	}	var t = document.getElementById('__wordCount__');	var t1 = document.getElementById('__wordCount1__');	if (t) {		t.innerHTML = '['+__lang('current')+ editor.document.body.innerHTML.length + __lang('word') + (_maxCount > 0 ? ','+__lang('maxword')+ _maxCount + __lang('word') : '') + ']';	}	if (t1) {		t1.innerHTML = '['+__lang('current') + textObj.value.length +  __lang('word') + (_maxCount > 0 ? ','+__lang('maxword') + _maxCount + __lang('word') : '') + ']';	}	if (_calcCountTimer) {		window.clearTimeout(_calcCountTimer);	}	_calcCountTimer = window.setTimeout('calcWordCount()', 1000);}var _img = null;function getImage() {	if (!textObj || !isIE5) {		return;	}	var img = new Object();	img.sFromUrl = '';	img.sBorder = '0';	img.sAlign = '';	img.control = null;	img.has = false;	var oSelection = editor.document.selection.createRange();	var sRangeType = editor.document.selection.type;	if (sRangeType == "Control") {		if (oSelection.item(0).tagName == "IMG"){			oControl = oSelection.item(0);			img.sFromUrl = oControl.src;			var b = oControl.style.border;			if (b) {				img.sBorder = b.replace(/.*([0-9]+)px.+/g, '$1');			}else {				img.sBorder = oControl.style.border;			}			img.sAlign = oControl.align;			img.has = true;			img.control = oControl;		}	}	return img;}var _link = null;function getLink() {	if (!textObj || !isIE5) {		return;	}	var link = new Object();	link.url = '';	link.target = '_blank';	link.control = null;	link.has = false;	if (rng) {		var isA;		if (sel.type == 'Control') {			isA = getEl('A', rng.item(0));		}else {			try {				isA = getEl("A", rng.parentElement());			}catch(e) {				isA = getEl('A', rng.item(0));			}		}		if (isA) {			link.url = isA.href ? isA.href : "";			link.target = isA.target;			link.control = isA;			link.has = true;		}	}	return link;}function insertImage() {	if (!textObj || !isIE5) {		return;	}	_img = getImage();	var text = dialogMsg['insertImg'];	if (_img.has) {		text = text.replace(/\{op\}/g, __lang('modify'));	}else {		text = text.replace(/\{op\}/g, __lang('insert'));	}	text = text.replace(/\{url\}/g, _img.sFromUrl);	text = text.replace(/\{border\}/g, _img.sBorder);	ShowDialogIn(text, 280, 150, false);}function insertLink() {	if (!textObj || !isIE5) {		return;	}	_link = getLink();	var text = dialogMsg['insertLink'];	if (_link.has) {		text = text.replace(/\{op\}/g, __lang('modify'));	}else {		text = text.replace(/\{op\}/g, __lang('insert'));	}	text = text.replace(/\{url\}/g, _link.url);	if (_link.target == '_blank') {		text = text.replace(/\{target\}/g, 'checked');	}else {		text = text.replace(/\{target\}/g, '');	}	ShowDialogIn(text, 280, 150, false);}function doInsertLink() {	reselect();	var url = document.getElementById('d_url').value;	var target = document.getElementById('d_target').checked;	if ( url != "" ) {		if (_link && _link.control) {			var o = _link.control;			o.href = url;			if (target) {				o.target = '_blank';			}else {				o.target = '_self';			}		}else {			editor.document.execCommand("CreateLink", "", url);			var l = getLink();			if (l.has && target && l.control) {				l.control.target = '_blank';			}		}	}	closeDialog();}function doInsertImage(img){	if (!textObj || !isIE5) {		return;	}	sFromUrl = document.getElementById('d_fromurl').value;	sBorder = document.getElementById('d_border').value;	sAlign = document.getElementById('d_align').value;	img = _img;	if (img && img.has && img.control) {		editor.focus();		var oControl = img.control;		oControl.src = sFromUrl;		try {		oControl.style.border = sBorder + 'px solid #000000';		}catch (eee) {}		oControl.align = sAlign;	}else{		reselect();		if (sFromUrl && sFromUrl.indexOf('http://cn.f11.yahoofs.com/users/') == 0) {			try {				AJAX(function(e) {					var newImg = e.responseText;					if (!newImg || newImg.indexOf('http://cn') != 0) {						newImg = sFromUrl;					}					var sHTML = '<img src="'+newImg+'" style="border:'+sBorder+'px  solid #000000;" align="'+sAlign+'">';					insertHTML(sHTML);				}, 'get', '/auction/transformYahooUrlGateway.do?src=' + sFromUrl, false, null, null, null, function(e) {					var sHTML = '<img src="'+sFromUrl+'" style="border:'+sBorder+'px  solid #000000;" align="'+sAlign+'">';					insertHTML(sHTML);				});			}catch (e) {				alert(e);			}		}else {			var sHTML = '<img src="'+sFromUrl+'" style="border:'+sBorder+'px  solid #000000;" align="'+sAlign+'">';			insertHTML(sHTML);		}	}	closeDialog();}//colorvar _stColorType = 1;function setStColor(color) {	if (!textObj || !isIE5) {		return;	}	if (_stColorType == 1) {		applyCommand('ForeColor', color);	}else if (_stColorType = 2) {		applyCommand('BackColor', color);	}else {		debug('no this type');	}	closeDialog();}function getEl(sTag,start) {	while ((start!=null) && start.tagName && (start.tagName!=sTag)){		start = start.parentElement;	}	return start;}

⌨️ 快捷键说明

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