ie5script.js

来自「类似youtube的视频分享网站源码。有后台管理系统及模板」· JavaScript 代码 · 共 923 行 · 第 1/3 页

JS
923
字号
	// end 222
	// the editor is now ready to use
	document.getElementById(obj.name+"_load_message").style.display ='none'
}
function wp_mouseUpHandler(obj, evt) {
	wp_set_button_states(obj)
	wp_hide_menu(obj)
	wp_current_obj = obj
}
// functions for sending html between edit_object and the textarea
function  wp_send_to_html(obj) {
	if (obj.html_edit_area.value.search(/<body/gi) != -1) {
		obj.snippit = false
		obj.html_edit_area.value = wp_gethtml(obj.edit_object.document,obj)
	} else {
		obj.snippit = true
		obj.html_edit_area.value = wp_gethtml(obj.edit_object.document.body,obj)
	}
	var str=obj.html_edit_area.value
	RegExp.multiline = true
	if (obj.domain1 && obj.domain2) {
		str = str.replace(obj.domain1, '$1"')
		str = str.replace(obj.domain2, '$1"')
	}
	//str = str.replace(/<div><\/div>/gi, "<div>&nbsp;</div>")
	//str = str.replace(/<p><\/p>/gi, "<p>&nbsp;</p>")
	str = str.replace(/ style=\"\"/gi, "")
	obj.html_edit_area.value = str 
}
function wp_send_to_edit_object(obj) { 
	str = obj.html_edit_area.value;
	str = wp_replace_bookmark (str)
	str = str.replace(/<%([^%]+)%>/gi, "<!--asp$1-->")
	str = str.replace(/<br><\/br>/gi, "<br />")
	obj.html_edit_area.value = str
	wp_next(obj)
	if (obj.border_visible == 1) {
		wp_show_borders(obj) 
	} 
	obj.styles = wp_make_styles (obj)
	obj.format_frame.written = false
	obj.class_frame.written = false
	obj.font_frame.written = false
	obj.size_frame.written = false
}
function wp_closePopup() {
  if (wp_oPopUp) {
		wp_oPopUp.hide()
	}
}
// Catch and execute the commands sent from the buttons and tools
function wp_callFormatting(obj,sFormatString) {
	obj.edit_object.focus()
	if (wp_is_ie50) {
		obj.edit_object.document.execCommand(sFormatString)
	} else {
		document.execCommand(sFormatString)
	}
	wp_set_button_states(obj)
}
function wp_change_class(obj,classname) {	
	wp_hide_menu(obj)
	obj.edit_object.focus()
	var sel = obj.edit_object.document.selection.createRange() 
	if (sel.text == '') {
		return;
	}
	var foo = sel.parentElement();
	//wp_font_hack(obj.edit_object.document, obj)
	if (classname == 'wp_none') {
		while(!foo.className&&foo.tagName!="HTML") {
			foo = foo.parentElement;
		}
		if (foo.getAttribute('class') != 'wp_none' && foo.getAttribute('class') != '') {
			foo.className = classname;
		}
	}
	if (obj.edit_object.document.selection.type == "Control") {
		sel(0).setAttribute('class', classname)	
	} else {
		obj.edit_object.document.execCommand("FontName", false, 'wp_bogus_font')
		var spans = obj.edit_object.document.getElementsByTagName('SPAN')
		var fonts = obj.edit_object.document.getElementsByTagName('FONT')
		wp_set_class(spans, classname, true)
		wp_set_class(fonts, classname, true)
	}
	wp_span_hack(obj.edit_object.document, obj)
} 
function wp_set_class(arr, classname, fontCheck) {
	var l = arr.length
	for (var i=0; i < l; i++) {
		if (fontCheck) {
			if (arr[i].style.fontFamily) {
				if (arr[i].style.fontFamily == 'wp_bogus_font') {
					arr[i].className = classname
					arr[i].style.fontFamily = ''
					// do children
					var spans = arr[i].getElementsByTagName('SPAN')
					var fonts = arr[i].getElementsByTagName('FONT')
					wp_set_class(spans, classname, false)
					wp_set_class(fonts, classname, false)
				}
			}
			if (arr[i].getAttribute("face")) {
				if (arr[i].getAttribute("face") == 'wp_bogus_font') {
					arr[i].removeAttribute('face')
					arr[i].className = classname
					// do children
					var spans = arr[i].getElementsByTagName('SPAN')
					var fonts = arr[i].getElementsByTagName('FONT')
					wp_set_class(spans, classname, false)
					wp_set_class(fonts, classname, false)
				}
			} 
		} else if (arr[i].getAttribute('class') != 'wp_none' && arr[i].getAttribute('class') != '') {
			if (arr[i].getAttribute('class') == classname) {
				arr[i].className = 'wp_none'
			} else {
				arr[i].className = classname;
			}
		}
	}
}
// lets try to make a custom hyperlink window!!
function wp_open_hyperlink_window(obj,srcElement) {
	var data = wp_generic_link_window_function (obj, srcElement)
	if (data) {
		var thisTarget = data['target']
		var thisTitle = data['title']
		var szURL= wp_directory +  "dialog_frame.php?target="+thisTarget+"&title="+thisTitle+"&lang="+obj.instance_lang+"&window="+wp_directory+"hyperlink.php"
		linkwin = obj.openDialog (szURL ,'modal',650,394)
	}
}
// link to a document
function wp_open_document_window(obj,srcElement) {
	var data = wp_generic_link_window_function (obj, srcElement)
	if (data) {
		var szURL= wp_directory + "dialog_frame.php?window="+wp_directory+"document.php&instance_doc_dir="+obj.instance_doc_dir+"&lang="+obj.instance_lang
		docwin = obj.openDialog(szURL ,'modal',730,466)
	}
}
function wp_generic_link_window_function (obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	var sel = obj.edit_object.document.selection.createRange()
	if ((sel.text == '') && (!wp_isInside(obj, 'A'))) {
		alert(obj.lng['select_hyperlink_text'])
		return
	}
	var thisTarget = ""
	var thisTitle = ""
	// check if hyperlink exists and if so populate the link dialog so that user can edit the existing link
	if (obj.edit_object.document.selection.type == "Control") {
		if (sel(0).tagName == "IMG") {
			this_href = sel(0).parentNode
		} else {
			return
		}
	} else {	
		this_href = sel.parentElement()
	}
	while(this_href.tagName!="A"&&this_href.tagName!="HTML") {
			this_href = this_href.parentElement
	}
	if (this_href.tagName == "A") {
		var thisLink = this_href.getAttribute("HREF", 2)
		wp_current_hyperlink = thisLink
		if (this_href.getAttribute("target")) {
			thisTarget = this_href.getAttribute("target")
		}
		if (this_href.getAttribute("title")) {
			thisTitle = this_href.getAttribute("title")
		}
	} else {
		wp_current_hyperlink = ''
	}
	return {'target': thisTarget,  'title': thisTitle}
}
// this creates the hyperlink html from data sent from the hyperlink window
function wp_hyperlink(obj,iHref,iTarget,iTitle) {
	// if no link data sent then unlink any existing link
	if (iHref=="") { 
			wp_callFormatting(obj, "Unlink")
			obj.edit_object.focus()
			return
	} else if(iHref=="file://") { 
			wp_callFormatting(obj, "Unlink")
			obj.edit_object.focus()
			return
	} else if(iHref=="http://") { 
			wp_callFormatting(obj, "Unlink")
			obj.edit_object.focus()
			return
	} else if(iHref=="https://") { 
			wp_callFormatting(obj, "Unlink")
			return
	} else if(iHref=="mailto:") { 
			wp_callFormatting(obj, "Unlink")
			obj.edit_object.focus()
			return
	} else { 
		var sel = obj.edit_object.document.selection.createRange()
		// create link
		sel.execCommand("CreateLink",false,iHref)
		// add target inf
		if (obj.edit_object.document.selection.type == "Control") {
			var sel = obj.edit_object.document.selection.createRange()
			if (sel(0).tagName == "IMG") {
				this_href = sel(0).parentNode
				sel(0).border = 0
			}
		} else {
			this_href = sel.parentElement()
		}
		while(this_href.tagName!="A"&&this_href.tagName!="HTML") {
			this_href = this_href.parentElement
		}
		if (this_href.tagName == "A") {
			if (iTarget != '' || this_href.target != '') {
				this_href.target=iTarget
			}
			if (iTitle != '' || this_href.title != '') {
				this_href.title=iTitle
			}
		}
	}
	obj.edit_object.focus()
}
// insert image
function wp_open_image_window(obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	obj.edit_object.focus()
	var szURL
	// detect if an image is selected and if it is populate image dialoge
	if (obj.edit_object.document.selection.type == "Control") {
		var sel = obj.edit_object.document.selection.createRange()
		if (sel(0).tagName == "IMG") {
			if ((sel(0).getAttribute('name')) && (sel(0).src.search(wp_directory+"/images/bookmark_symbol.gif") != -1)) {
				szURL= wp_directory + obj.imagewindow + "?lang="+obj.instance_lang
			} else {
				var image = sel(0).getAttribute('src', 2)
				if (sel(0).style.height) {
					str = sel(0).style.height
					var height = str.replace(/px/, '')
				} else {
					var height = sel(0).getAttribute('height', 2)
				}
				if (sel(0).style.width) {
					str = sel(0).style.width
					var width = str.replace(/px/, '')
				}	else {
					var width = sel(0).getAttribute('width', 2)
				}
				var alt = sel(0).getAttribute('alt')
				var align = sel(0).getAttribute('align')
				var mtop = sel(0).style.marginTop 
				var mbottom = sel(0).style.marginBottom 
				var mleft = sel(0).style.marginLeft 
				var mright = sel(0).style.marginRight 
				var thisIHeight = sel(0).getAttribute('height')
				var iborder = sel(0).getAttribute('border')
				szURL= wp_directory + 'dialog_frame.php' + '?image=' + image +'&width=' + width +'&height=' + height + '&alt=' + alt + '&align=' + align + '&mtop=' + mtop + '&mbottom=' + mbottom + '&mleft=' + mleft + '&mright=' + mright + '&border=' + iborder + "&lang="+obj.instance_lang +"&window="+wp_directory+"imageoptions.php" 
			}
		} else {
			return
		}
	} else {
		szURL= wp_directory + 'dialog_frame.php?window=' + wp_directory + obj.imagewindow + "&instance_img_dir="+obj.instance_img_dir+"&lang="+obj.instance_lang 
	}
	imgwin = obj.openDialog(szURL ,'modal',730,466)
}
// create the image html
function wp_create_image_html(obj,iurl, iwidth, iheight, ialign, ialt, iborder, imargin) {
	if (iurl == ""){
		return
	}
	obj.edit_object.focus()
	if (document.getElementById(obj.name+'_class_menu-text').innerHTML != "Class")
		document.getElementById(obj.name+'_class_menu-text').innerHTML = "Class"
	var sel = obj.edit_object.document.selection.createRange()
	sel.execCommand("InsertImage",false, iurl)
	if (obj.edit_object.document.selection.type == "Control") {
		var sel = obj.edit_object.document.selection.createRange()
		if (sel(0).tagName == "IMG") {
			if ((iwidth != '') && (iheight!='') && (iwidth != 0) && (iheight!=0) && (iheight!=null)) {
				if (iheight.search("%") != -1) {
					sel(0).style.height = iheight
					sel(0).height = iheight
				} else {
					sel(0).setAttribute("height",  iheight)
					sel(0).style.height = ''
				}
				if (iwidth.search("%") != -1) {
					sel(0).style.width = iwidth
					sel(0).width = iwidth
				} else {
					sel(0).setAttribute("width", iwidth)
					sel(0).style.width = ''
				}
			}
			if ((ialign != '') && (ialign!=0) && (ialign!=null)) {
				sel(0).align = ialign
			}
			if ((iborder != '') && (iborder!=null)) {
				sel(0).border = iborder

⌨️ 快捷键说明

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