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

📄 editorshared.js

📁 类似youtube的视频分享网站源码。有后台管理系统及模板
💻 JS
📖 第 1 页 / 共 4 页
字号:
// Purpose: functions shared between all supported browsers
window.onerror = wp_hide_error
var wp_version="2.2.4"
var image_action = false
var wp_thisRow = null
var wp_thisCell = null
var wp_thisTable = null
var wp_current_hyperlink = null
var wp_current_obj=null
var wp_debug_mode = false
var wp_inbase = false
// 222
var wp_donetext = null
var wp_ignore_next = false
// tag groups
var wp_inline_tags = /^(a|abbr|acronym|b|bdo|big|br|cite|code|dfn|em|font|i|img|kbd|label|q|s|samp|select|small|span|strike|strong|sub|sup|textarea|tt|u|var)$/i;
var wp_cant_have_children = /^(script|meta|link|input|br|hr|spacer|img|bgsound|embed|param|wbr|area|applet|object|basefont|style|title|comment|textarea|iframe)$/i;
var wp_cant_have_children_has_close_tag = /^(textarea|iframe|embed|object|applet)$/i;
var wp_boolean_attributes = /^(nowrap|ismap|declare|noshade|checked|disabled|readonly|multiple|selected|noresize|defer)$/i;
var wp_supported_blocks = /^(h1|h2|h3|h4|h5|h6|p|div|address|pre)$/i;
var wp_not_specified_ignore = /^(selected|coords|shape|type|value)$/i;
var wp_bogus_attributes = /^(_base_href|_moz_dirty|_moz_editor_bogus_node|_done)$/i;
var wp_attribute_allowed_empty = /^(alt|title|action|href|src|value)$/i;
var wp_attribute_case_must_lower = /^(align|valign|shape|type)$/i;
var wp_link_attributes = /^(src|href|action)$/i;
// 222
function wp_config () {
	this.lang = []
	this.useXHTML = false
	this.usep = false
	this.showbookmarkmngr = true
	this.subsequent = false
	//this.border_visible = 1 // now set through a PHP function
}
// 222
function wp_font_hack(node, obj) {
	var spans = node.getElementsByTagName("SPAN")
	var n = spans.length
	var j = 0
	for (var i = 0; i < n; i++) {
		if (spans[j]) {
			if (spans[j].className || spans[j].style.cssText.length > 1) {
				var newNode = obj.edit_object.document.createElement("FONT")
				var attributes = spans[j].attributes
				wp_add_attributes(newNode, attributes, spans[j])
				wp_font_hack(spans[j], obj)
				newNode.innerHTML = spans[j].innerHTML
				try {
					spans[j].parentNode.insertBefore(newNode, spans[j].nextSibling)
					spans[j].parentNode.removeChild(spans[j]);
				} catch (e) {
					j++
				}
			} else {
				j++
			}
		} else {
			j++
		}
	}
}
function wp_span_hack(node, obj) {
	var fonts = node.getElementsByTagName("FONT")
	var n = fonts.length
	var j = 0
	for (var i = 0; i < n; i++) {
		if (fonts[j]) {
			if (fonts[j].className || fonts[j].style.cssText.length > 1 && (!fonts[j].getAttribute('face') && !fonts[j].getAttribute('size') && !fonts[j].getAttribute('color')) ) {
				var newNode = obj.edit_object.document.createElement("SPAN")
				var attributes = fonts[j].attributes
				wp_add_attributes(newNode, attributes, fonts[j])
				wp_font_hack(fonts[j], obj)
				newNode.innerHTML = fonts[j].innerHTML
				try {
					fonts[j].parentNode.insertBefore(newNode, fonts[j].nextSibling)
					fonts[j].parentNode.removeChild(fonts[j]);
				} catch (e) {
					j++
				}
			} else {
				j++
			}
		} else {
			j++
		}
	}
}

function wp_add_attributes(node, attributes, oldNode, ignore_unique) {
	var l = attributes.length
	for (var j = 0; j < l; j++) {
		if (attributes[j].nodeName=='id' && ignore_unique) {
			continue;
		} else if (attributes[j].specified && attributes[j].nodeName!='class' && attributes[j].nodeName!='style') {
			node.setAttribute(attributes[j].nodeName, attributes[j].nodeValue, 0)
		} else if (attributes[j].nodeName=='class') {
			node.className = attributes[j].nodeValue
		} else if (attributes[j].nodeName=='style') {
			if (oldNode) {
				node.style.cssText = oldNode.style.cssText
			} else {
				node.style.cssText = attributes[j].nodeValue
			}
		}
	}
}
// end 222
function wp_closePopupTimer() {
	setTimeout("wp_closePopup()", 100);
}
// wp_stringbuilder, wp_gethtml, wp_fixAttibute, wp_fixText, wp_getAttributeValue and wp_appendNodeHTML are based on "getXhtml" by Erik Arvidsson available from http://webfx.eae.net/ used under license.
function wp_StringBuilder(sString) {
	this.append = function (sString) {
		this.length += (this._parts[this._current++] = String(sString)).length
		this._string = null
		return this
	}
	this.toString = function () {
		if (this._string != null)
			return this._string
		var s = this._parts.join("")
		this._parts = [s]
		this._current = 1
		this.length = s.length
		return this._string = s
	}
	this._current	= 0
	this._parts		= []
	this._string	= null
	if (sString != null)
		this.append(sString)
}
function wp_gethtml(node,obj) {
	var sb = new wp_StringBuilder
	// 222
	wp_inbase = false
	wp_donetext = null
	wp_ignore_next = false
	// 222
	var cn = node.childNodes
	var n = cn.length
	for (var i = 0; i < n; i++) {
		wp_appendNodeHTML(cn[i], sb, obj)
	}
	// 222
	if (obj.html_mode!=true && wp_is_ie) {
		wp_remove_done(node, obj)
	}
	// end 222
	var doctype = ''
	if (obj.useXHTML && !obj.snippit) {
		doctype =  '<?xml version="1.0" encoding="' + obj.encoding + '"?>\n'+obj.doctype+'\n'
	} else if (!obj.useXHTML && !obj.snippit) {
		doctype =  obj.doctype+'\n'
	}
	var code = doctype + sb.toString()
	code = code.replace(/\s\n/gi, '\n');
	return code.trim()
}// 222
function wp_remove_done(node, obj) {
	var body = false
	if (node.nodeName) {
		if (node.nodeName == 'BODY') {
			body = true
		}
	}
	if (body) {
		node.removeAttribute("_done", 1);
		node.innerHTML = node.innerHTML.replace(/ _done="true"/gi, '')
	} else {
		if (node._done) {
			node.removeAttribute("_done",1);
		}
		var cn = node.childNodes
		var n = cn.length
		for (var i = 0; i < n; i++) {
			if (cn[i]._done) {
				cn[i].removeAttribute("_done",1);
			}
			wp_remove_done(cn[i], obj);
		}
	}
}
function wp_quoteMeta(str) {
	str = str.replace(/\//gi, '\\/');
	str = str.replace(/\./gi, '\\.');
	return str;
}
// end 222
function wp_fixAttribute(value) {
	return String(value).replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/\"/g, "&quot;")
}
function wp_fixText(text) {
	return String(text).replace(/\&/g, "&amp;").replace(/</g, "&lt;")
}
function wp_getAttributeValue(attrNode, elementNode, sb, obj) {
	var name = attrNode.nodeName.toLowerCase()
	if (wp_is_ie) {
		if ((name == 'selected') && (attrNode.nodeValue != true)) return
		if (!attrNode.specified && (!wp_not_specified_ignore.test(name) || (elementNode.nodeName == 'LI' && name == 'value') ) )
		return
	}
	if (wp_bogus_attributes.test(name)) {
		return
	}
	if (wp_boolean_attributes.test(name)) {
		var value = name
	} else {
		var value = attrNode.nodeValue
	}
	if (value == "" && (!wp_attribute_allowed_empty.test(name))) return
	if (name == "class" && value == "wp_none") return
	if (value == "null") return
	if (name != "style") {
		if (!isNaN(value)) {
			if (elementNode.nodeName == "IMG" || elementNode.nodeName == "TABLE" ) {
				if (name=='height' && elementNode.style.height) {
					var str = elementNode.style.height
					value = str.replace(/px/, '');
				} else if (name=='width' && elementNode.style.width) {
					var str = elementNode.style.width
					value = str.replace(/px/, '');
				}	else {
					value = elementNode.getAttribute(name, 2)
				}
			} else {
				value = elementNode.getAttribute(name, 2)
			}
		} else if (wp_attribute_case_must_lower.test(name)) {
			value = elementNode.getAttribute(name).toLowerCase()
		} else if (wp_link_attributes.test(name) && (obj.domain1 || value.search("#") != -1) ) {
			value = elementNode.getAttribute(name, 2)
			var string = document.location.toString();
			var string = string.split('#');
			var secure = new RegExp(wp_quoteMeta(string[0]),"gi");
			value = value.replace(secure, '')
		}
		sb.append(" " + name + "=\"" + wp_fixAttribute(value) + "\"")
	} 
}
function wp_appendNodeHTML(node, sb, obj) {
	switch (node.nodeType) {
		case 1:	// ELEMENT		
			if (node.nodeName == "!") {
				if ((node.text.search(/DOCTYPE/gi) != -1) || (node.text.search(/version=\"1.0\" encoding\=/gi) != -1)) {
					sb.append('')
				} else {
					sb.append(node.text)
				}
				break
			}
			var name = node.nodeName
			name = name.toLowerCase()
			// wp 222
			if (!name || name == '') {
				// childNodes
				var cs = node.childNodes
				l = cs.length
				for (var i = 0; i < l; i++) {
					wp_appendNodeHTML(cs[i], sb, obj)
				}
				break
			}
			if (name == '/embed') return
			// end wp 222
			if (wp_inbase == true && name == 'body') {
				break
			}	
			if (name == "base" && !wp_is_ie) {
				if (node.getAttribute('href') == obj.baseURLurl) {
					break
				}	
			} else if (name == "base") {
				wp_inbase = true
				// childNodes
				var cs = node.childNodes
				l = cs.length
				for (var i = 0; i < l; i++) {
					wp_appendNodeHTML(cs[i], sb, obj)
				}
				wp_inbase = false
				break
			}
			// 222 repition
			if (wp_ignore_next) {
				if (node.canHaveChildren && node.innerHTML == '') {
					wp_ignore_next = false
					break
				}
			}
			if (wp_is_ie) {
				if (node._done) {
					wp_ignore_next = true
					break;
				}
				node._done = true
			}
			// end 222
			if (name == "link" && obj.stylesheet != '') {
				var num = obj.stylesheet.length;
				var dobreak = false;
				for (var i=0; i < num; i++) {
					if (node.getAttribute('href') == obj.stylesheet[i]) {
						dobreak = true
						break
					}
				}
				if (dobreak) {
					break
				}
			}
			if (name == "meta") {
				if (node.getAttribute('name') ) {
					if (node.getAttribute('name').toLowerCase() == "generator" && wp_is_ie) {
						break
					}
				}
			}
			if (name == "img") {
				if ((node.getAttribute('name')) && (node.src.search(wp_directory+"/images/bookmark_symbol.gif") != -1)) {
					sb.append('<a name="'+node.getAttribute('name')+'"')
					if (obj.useXHTML) {
						sb.append(' id="'+node.getAttribute('name')+'"></a>')
					} else {
						sb.append('></a>')
					}
					break
				}
				if (!node.getAttribute("alt")) {
					node.setAttribute("alt", "")
				}
			}
			if (name == "area") {
				if (!node.getAttribute("alt")) {
					node.setAttribute("alt", "")
				}
			}
			if (!wp_inline_tags.test(name) && name != "html") {
				if (wp_is_ie) {
					sb.append("\n")
				} else if (name != 'tbody'
					&& name != 'thead'
					&& name != 'tfoot'
					&& name != 'tr'
					&& name != 'td') {
						sb.append("\n")
				}
			}
			// 222
			if (name == 'font' && !node.getAttribute('face') && !node.getAttribute('size') && !node.getAttribute('color')) {
				name="span"
			}
			// end 222
			if (((name == "span") || (name == "font")) && (node.style.cssText.length < 1))  {
				var attrs = node.attributes
				var l = attrs.length
				// IE5 fix: count specified attrs
				var n = 0
				for (var i = 0; i < l; i++) {
					if (attrs[i].specified) {
						n ++
					} 
				}
				if (wp_is_ie) { n1 = 1; } else { n1 = 0; }				
				// 222 font removal fix
				if (n == n1 || (n == (n1 + 1) && node.className == "wp_none") || (n == (n1 + 1) && node.face == "null")) {
					if (node.hasChildNodes()) {							
						// childNodes
						var cs = node.childNodes

⌨️ 快捷键说明

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