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

📄 editorshared.js

📁 类似youtube的视频分享网站源码。有后台管理系统及模板
💻 JS
📖 第 1 页 / 共 4 页
字号:
						l = cs.length
						for (var i = 0; i < l; i++) {
							wp_appendNodeHTML(cs[i], sb, obj)
						}
					}
					break
				}
				// end 222
			}
			sb.append("<" + name)
			if (name == "html" && obj.useXHTML) {
				if (!node.getAttribute('xmlns')) {
					sb.append(' xmlns="http://www.w3.org/1999/xhtml"')
				}
				if (!node.getAttribute('xml:lang')) {
					sb.append(' xml:lang="' + obj.xhtml_lang.toLowerCase() + '"')
				}
				if (!node.getAttribute('lang')) {
					sb.append(' lang="' + obj.xhtml_lang.toLowerCase() + '"')
				}
			}
			// inline styles
			if (node.style.cssText.length > 1) {
				sb.append(' style="')
				var propArray = node.style.cssText.split(';')
				var l = propArray.length
				for (var i = 0; i < l; i++) {
					if (propArray[i].length > 1) {
						var propVal = propArray[i].split(':')
						if (obj.border_visible == 1) {
							if (propVal[1] != " null"
							&& propVal[1] != " wp_bogus_font"
							&& propVal[1] != " 1px dashed rgb(127, 124, 117)"
							&& propVal[1] != " #7f7c75 1px dashed"
							&& propVal[0].substr(0,5) != " mso-"
							&& propVal[0].substr(0,4) != "mso-") {
								sb.append(propVal[0].toLowerCase() + ':')
								sb.append(wp_fixAttribute(propVal[1]) + ';')
							}
						} else {
							if (propVal[1] != " null"
							&& propVal[1] != " wp_bogus_font") {							
								sb.append(propVal[0].toLowerCase() + ':')
								sb.append(wp_fixAttribute(propVal[1]) + ';')
							}
						}
					}
				}
				sb.append('"')
			}
			// attributes
			var attrs = node.attributes
			var l = attrs.length
			for (var i = 0; i < l; i++) {
				wp_getAttributeValue(attrs[i], node, sb, obj)
			}
			// wp 222 iframe fix
			if (!wp_is_ie) {
				if (!wp_cant_have_children.test(name)) {
					node.canHaveChildren = true
				} else {
					node.canHaveChildren = false
				}
			}
			if ((node.canHaveChildren || node.hasChildNodes() || wp_cant_have_children_has_close_tag.test(name) ) && name != 'basefont' && name != 'script' && name != 'style' && name != 'title') {
				sb.append(">")
				if (( ( (wp_is_ie && node.innerHTML == '') || (wp_is_ie && node.innerHTML == ' ') ) || node.innerHTML == '&nbsp;') && node.canHaveChildren) {
				// end 222
					sb.append('&nbsp;')
				} else {
					// childNodes
					var cs = node.childNodes
					l = cs.length
					for (var i = 0; i < l; i++) {
						wp_appendNodeHTML(cs[i], sb, obj)
					}
					if ((name == 'body') || (name == 'html') || (name == 'head')) {
						sb.append("\n")
					}
				}
				sb.append("</" + name + ">")
			} else if (name == "script") {
				sb.append(">" + node.text + "</" + name + ">")
			} else if (name == "style") {
				sb.append(">" + node.innerHTML.trim() + "</" + name + ">")
			} else if (name == "title" || name == "comment") {
				sb.append(">" + node.innerHTML + "</" + name + ">")
			} else if (obj.useXHTML) {
				sb.append(" />")
			} else { 
				sb.append(">")
			}
			if (name == 'br') {
				sb.append("\r")
			}
			break
		case 3:	// TEXT
			if (node.nodeValue) {
				// 222 repitition fix
				if (wp_donetext == node) {
					wp_donetext = null;
					break
				}
				if (wp_is_ie) {
					wp_donetext = node
				}
				// end 222
				if (node.nodeValue == '\n' ) break
				var str = node.nodeValue
				sb.append( wp_fixText( str.dblTrim() ))
			}
			break
		case 4:
			sb.append("<![CDA" + "TA[\n" + node.nodeValue + "\n]" + "]>")
			break
		case 8:
			if (wp_is_ie) {
				if ((node.text.search(/DOCTYPE/gi) != -1) || (node.text.search(/version=\"1.0\" encoding\=/gi) != -1)) {
					sb.append('')
				} else {
					sb.append("<!--" + node.nodeValue + "-->")
				}
			} else {
				if (node.nodeValue.substr(0, 4) == "[if ") {
					return
				} else {
					sb.append("<!--" + node.nodeValue + "-->")
				}
			}
			break
		case 9:	// DOCUMENT
			// childNodes
			var cs = node.childNodes
			l = cs.length
			for (var i = 0; i < l; i++) {
				wp_appendNodeHTML(cs[i], sb, obj)
			}
			break
		case 10:
			sb.append('')
			break
		default:
			if (wp_debug_mode) {
				sb.append("<!--\nUnsupported Node:\n\n" + "nodeType: " + node.nodeType + "\nnodeName: " + node.nodeName + "\n-->")
			}
	}
}
function wp_replace_bookmark (code) {
	code = code.replace(/<a name="([^"]+)[^>]+><\/a>/gi, "<img name=\"$1\" src=\"" + wp_directory + "/images/bookmark_symbol.gif\" contenteditable=\"false\" width=\"16\" height=\"13\" title=\"Bookmark: $1\" alt=\"Bookmark: $1\" border=\"0\">")
	code = code.replace(/<a name="([^"]+)[^>]+>&nbsp;<\/a>/gi, "<img name=\"$1\" src=\"" + wp_directory + "/images/bookmark_symbol.gif\" contenteditable=\"false\" width=\"16\" height=\"13\" title=\"Bookmark: $1\" alt=\"Bookmark: $1\" border=\"0\">")
	return code
}
// this project is getting so complex we need to block any errors that I may not have accounted for
function wp_hide_error(evt) {
	if (!wp_debug_mode) {
		if (evt.stopPropagation) {
			evt.stopPropagation()
			evt.preventDefault()
		}
		return true
	}
}
function wp_make_styles (obj) {
	var styles = ''
	if (obj.stylesheet != '') {
		var num = obj.stylesheet.length;
		for (var i=0; i < num; i++) {
			styles += '<link rel="stylesheet" href="'+obj.stylesheet[i]+'" type="text/css">'
		}
	}
	var stylesheets = obj.edit_object.document.getElementsByTagName('link')
	var l=stylesheets.length
	for (var i=0; i < l; i++) {
		if (stylesheets[i].href) {
			if (stylesheets[i].rel) {
				if (stylesheets[i].rel.toLowerCase() == "stylesheet") {
					styles += '<link rel="stylesheet" href="'+ stylesheets[i].href +'" type="text/css">'
				}
			} else if (stylesheets[i].type) {
				if (stylesheets[i].type.toLowerCase() == "text/css") {
					styles += '<link rel="stylesheet" href="'+ stylesheets[i].href +'" type="text/css">'
				}		
			}
		}
	}	
	var styleTags = obj.edit_object.document.getElementsByTagName('style')
	var l=styleTags.length
	for (var i=0; i < l; i++) {
		styles += '<style type="text/css">'+ styleTags[i].innerHTML +'</style>'
	}
	return styles
}
// 222
function wp_show_menu(obj, type, srcElement) {	
	var frame = document.getElementById(obj.name+"_"+type+"_frame")
	if (frame.style.display=="none") {
		wp_hide_menu(obj)
		wp_current_obj = obj
		parent.command = srcElement.id
		frameObj = eval(obj.name+"."+type+"_frame")
		try {
			if (!frameObj.written) {
			 var writeIt = true
			} else {
			 var writeIt = false
			}
		} catch (e) {
			 var writeIt = true
		}
		if (writeIt) {
			var frameDoc = eval(obj.name+"."+type+"_frame.document")
			var menu_code
			if (obj.styles == '') {
				obj.styles = wp_make_styles(obj)
			}
			if (wp_is_ie) {
				var border = "border: 1px solid #000000"
			} else {
				var border = ""
			}
			var head = '<style type="text/css">body {background-color:white; padding:0px; margin:0px; ' + border + '} .off { display:block; overflow:hidden; width:249px; border: 2px solid #eeeeee; cursor: pointer; cursor: hand; } .on { display:block; overflow:hidden; width:249px; border: 2px solid highlight; cursor: pointer; cursor: hand; } div {padding: 0px; margin: 1px 0px 0px 0px}</style><script type="text/javascript">function on (elm) {elm.className="on";} function off (elm) {elm.className="off";}</script></head>'
			var head2 = '<html><head><style type="text/css">body {background-color:white; padding:0px; margin:0px; color:black; ' + border + '} .off { display:block; overflow:hidden; width:270px; background-color:white; color:black; padding: 2px; cursor: pointer; cursor: hand; } .on { display:block; overflow:hidden; width:270px; background-color:highlight; color:highlighttext; padding: 2px; cursor: pointer; cursor: hand; } div {text-align:left; padding:0px; margin: 1px 0px 0px 0px}</style><script type="text/javascript">function on (elm) {elm.className="on";} function off (elm) {elm.className="off";}</script></head>'
			if (type=="font") {
				menu_code = obj.baseURL + '<html><head>' + obj.styles + head2 + '<style>div {font-size:16px}</style><body><div id="container" style="margin-top:0px; width:253px; overflow:hidden; left: 0px; top:0px; position:absolute;">'+ document.getElementById(obj.name+"_font-menu").innerHTML +'<div></body></html>'
			} else if (type=="size") {
				menu_code = obj.baseURL + '<html><head>' + obj.styles + head2 + '<body><div id="container" style="margin-top:0px; width:93px; overflow:hidden; left: 0px; top:0px; position:absolute;">'+ document.getElementById(obj.name+"_size-menu").innerHTML +'<div></body></html>'
			} else if (type=="format") {
				menu_code = obj.baseURL + '<html><head>' + head + obj.styles + '<body><div id="container" style="margin:0px; padding:0px; width:253px; overflow:hidden; left: 0px; top:0px; position:absolute;">'+ document.getElementById(obj.name+"_format-menu").innerHTML +'<div></body></html>'
			} else if (type=="class") {
				menu_code = obj.baseURL + '<html><head>' + head + obj.styles + '<body><div id="container" style="margin:0px; padding:0px; width:253px; overflow:hidden; left: 0px; top:0px; position:absolute;">'+ document.getElementById(obj.name+"_class-menu").innerHTML +'<div></body></html>'
			}
			frame.style.display="block"
			frameDoc.open()	
			frameDoc.write(menu_code)
			frameDoc.close()
			try {
			frameObj.written = true
			} catch (e) {
			}
			setTimeout("wp_set_menu_height("+obj.name+", '"+type+"')", 400)
		} else {
			frame.style.display="block"
		}
	} else {
		wp_hide_menu(obj)
	}
}
function wp_set_menu_height (obj, type) {
	try {
		maxHeight = 202
		var docHeight = document.getElementById(obj.name+'_editFrame').height
		//var docHeight = docHeight.replace(/px/, '')
		if (docHeight > 190) {
			maxHeight = docHeight - 12
		}
		var frame = document.getElementById(obj.name+"_"+type+"_frame")
		if (wp_is_ie) {
			var height = document.frames(obj.name+"_"+type+"_frame").document.getElementById('container').offsetHeight
		} else {
			var height = document.getElementById(obj.name+"_"+type+"_frame").contentWindow.document.getElementById('container').offsetHeight
		}
		if (height < maxHeight && height > 0) {
			frame.height = height + 2
		} else {
			frame.height = maxHeight
		}
	} catch (e) {
		return
	}
}
function wp_hide_menu(obj) {
	document.getElementById(obj.name+"_format_frame").style.display="none"
	document.getElementById(obj.name+"_class_frame").style.display="none"
	document.getElementById(obj.name+"_font_frame").style.display="none"
	document.getElementById(obj.name+"_size_frame").style.display="none"
}
// end 222
function wp_remove_attributes(collection, attribute) {
	var n = collection.length
	for (var i = 0; i < n; i++) {
		if (collection[i].getAttribute(attribute)) {
			if (collection[i].getAttribute(attribute) == 'null') {
				collection[i].removeAttribute(attribute)
			}
		}
	}
}
function wp_change_font_size(obj,size) {
	wp_hide_menu(obj)	
	obj.edit_object.focus()
	if (size == 'Default') {
		obj.edit_object.document.execCommand("RemoveFormat", false, null)
	} else {
		obj.edit_object.document.execCommand("FontSize", false, size)
	}
	/////
	if (size == 'null') {
		var fonts = obj.edit_object.document.getElementsByTagName("FONT")
		wp_remove_attributes(fonts, 'size')
	}
}
function wp_change_font(obj,font) {
	wp_hide_menu(obj)
	obj.edit_object.focus()
	if (font == 'Default') {
		obj.edit_object.document.execCommand("RemoveFormat", false, null)
	} else {
		obj.edit_object.document.execCommand("FontName", false, font)
	}
	////
	if (font == 'null') {
		var fonts = obj.edit_object.document.getElementsByTagName("FONT")
		wp_remove_attributes(fonts, 'face')
	}
}
function wp_change_format(obj,format) {
	wp_hide_menu(obj)
	obj.edit_object.focus()
	if (!wp_is_ie) {
		// add attributes back in because formatblock removes them in mozilla
		var sel = obj.edit_object.getSelection()
		var range = sel.getRangeAt(0)
		var container = range.startContainer
		var textNode = container
		container = textNode.parentNode
		var parentTag = wp_skipInline(container)
		// can't safley continue if this is not a supported tag for the formatblock command
		if (parentTag.tagName) {
			if ( !wp_supported_blocks.test(parentTag.tagName.toLowerCase() ) ) {
				obj.edit_object.document.execCommand("FormatBlock", false, format)
				return
			}
		}
		var attributes = parentTag.attributes
		obj.edit_object.document.execCommand("FormatBlock", false, format)
		container = textNode.parentNode
		// add attributes back	
		var parentTag = wp_skipInline(container)
		wp_add_attributes(parentTag, attributes)
	} else {
		obj.edit_object.document.execCommand("FormatBlock", false, format)
	}
}
function wp_colordialog(obj,srcElement, Action) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	var action = obj.openDialog(wp_directory + "selcolor.php?action="+Action+"&lang="+obj.instance_lang , 'modal', 296, 352)
}
// opens a modal dialoge, returns the window opject or return value in the case of modal windows.
function wp_docolor(obj,Action,color) {   
	obj.edit_object.focus()
	if (!wp_is_ie && color == '') {
		if (Action == 'hilitecolor') {
			color = 'rgb(127, 124, 117)'
		} else {
			color = 'null'
		}
	}
	if (Action == 'hilitecolor') {
		obj.edit_object.document.execCommand("usecss", false, false)
		obj.edit_object.document.execCommand('hilitecolor', false, color)
		obj.edit_object.document.execCommand("usecss", false, true)
	} else {
		obj.edit_object.document.execCommand(Action, false, color)
	}
	////
	if (!wp_is_ie) {
		if (Action == 'forecolor' && color == 'null' ) {

⌨️ 快捷键说明

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