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

📄 mozscript.js

📁 类似youtube的视频分享网站源码。有后台管理系统及模板
💻 JS
📖 第 1 页 / 共 4 页
字号:
	}
	wp_insertNodeAtSelection(obj.edit_object, hr)
	obj.edit_object.focus()
}
function wp_insert_code(obj,code) {
	if ((code != "") && (code != null)) {
		obj.edit_object.focus()
		span = obj.edit_object.document.createElement("SPAN")
		span.innerHTML = code
		wp_insertNodeAtSelection(obj.edit_object, span)
	}
	if (obj.border_visible == 1) {
		wp_show_borders(obj)
	}
	obj.edit_object.focus()
}
function wp_open_bookmark_window(obj,srcElement) {	
	var szURL
	var range = obj.edit_object.getSelection().getRangeAt(0)
	var container = range.startContainer
	var pos = range.startOffset
	var imageNode = null
	var arr= ''
	if (container.tagName) {
		var images = container.getElementsByTagName('IMG')
		var cn = container.childNodes
		if (cn[pos]) {
			if (cn[pos].tagName == 'IMG') {
				imageNode = cn[pos]
				if ((imageNode.getAttribute('name')) && (imageNode.src.search(wp_directory+"/images/bookmark_symbol.gif") != -1)) {
					arr = imageNode.name
				}
			}
		}
	}
	bookwin = obj.openDialog(wp_directory + "bookmark.php?bookmark="+arr+"&lang="+obj.instance_lang, "modal", 300, 106)
}
function wp_create_bookmark (obj,name) {
	if ((name != '') && (name!= null)) {
		img = obj.edit_object.document.createElement("img")
		img.setAttribute('src', wp_directory + '/images/bookmark_symbol.gif')
		img.setAttribute('name', name)
		img.setAttribute('width', 16)
		img.setAttribute('height', 13)
		img.setAttribute('alt', 'Bookmark: ' + name)
		img.setAttribute('title', 'Bookmark: ' + name)
		img.setAttribute('border', 0)
		wp_insertNodeAtSelection(obj.edit_object, img)
	}
}
////////////////////////////
// Table editing features //
////////////////////////////
// finds the current table, row and cell and puts them in global variables that the other table functions and the table editing window can use.
// requires the current selection
function wp_getTable(obj) {
	var sel = obj.edit_object.getSelection()
 	var range = sel.getRangeAt(0)
	var container = range.startContainer
	if (container.nodeType != 1) {
		var textNode = container
    	container = textNode.parentNode
	}
	wp_thisCell = container
	while(wp_thisCell.tagName!="TD"&&wp_thisCell.tagName!="BODY") {
		wp_thisCell = wp_thisCell.parentNode
	}
	wp_thisRow = wp_thisCell
	while(wp_thisRow.tagName!="TR"&&wp_thisRow.tagName!="BODY") {
		wp_thisRow = wp_thisRow.parentNode
	}
	wp_thisTable = wp_thisRow
	while(wp_thisTable.tagName!="TABLE"&&wp_thisTable.tagName!="BODY") {
			wp_thisTable = wp_thisTable.parentNode
	}
}
// edit table window
// creates the table html for the insert table window
function wp_insertTable(obj,rows,cols,width,percent1, height,percent2,  border, bordercolor, bgcolor, cellpadding, cellspacing, bCollapse) {
	//edit_object.focus()
		// generate column widths
	table = obj.edit_object.document.createElement("table")
	if (border!='') {
		table.setAttribute("border", border)
	}	
 	if (bordercolor != "") {
 		table.setAttribute("bordercolor", bordercolor)
	} 
	if (cellpadding != "") {
 		table.setAttribute("cellpadding", cellpadding)
	}
	if (cellspacing != "") {
 		table.setAttribute("cellspacing", cellspacing)
	}
 	if (bgcolor != "") {
 		table.setAttribute("bgcolor", bgcolor)
	}
 	if (width != "") {
 		table.setAttribute("width", width+percent1)
	}
 	if (height != "") {
 		table.setAttribute("height", height+percent2)
	}
 	if (bCollapse == true) {
 		table.style.borderCollapse = "collapse"
	}
	var tdwidth = 100/cols
	tdwidth +="%"
	for (var i = 0; i < rows; i++) {
		row = obj.edit_object.document.createElement("tr")
    for (var j = 0; j < cols; j++) {
			cell = obj.edit_object.document.createElement("td")
			cell.setAttribute("valign", 'top')
			cell.setAttribute("width", tdwidth)
			cell.innerHTML = obj.tdInners
			row.appendChild(cell)
  	}
    table.appendChild(row)
	}
	obj.edit_object.focus()
	wp_insertNodeAtSelection(obj.edit_object, table)
	if (obj.border_visible == 1) {
		wp_show_borders(obj)
	}
	wp_send_to_html(obj)
	wp_send_to_edit_object(obj)
}
/////////////////////////
// CSS style functions //
/////////////////////////
// mouse over button style
// these fucntions are still a little messey!!!!!!
// mouse over button style
function wp_m_over(element, obj) {
	if (obj.initfocus == false) {
		return
	}
	var cmd = element.getAttribute("cid")
	if (element.className=="wpDisabled") {
		return
	}
	if ((cmd=="edittable") || (cmd=="splitcell")) {
		cmd="inserthorizontalrule"
	}
	if (cmd == "border") {
		if (obj.border_visible) {
			element.className="wpLatchedOver"
		} else {
			element.className="wpOver"
		}
		return
	} else if (cmd=="ignore") {
		element.className="wpOver"
		return	
	} else if ((cmd=="undo") ||  (cmd=="redo")) {
		element.className="wpOver"
		return
	} else {
		try {
			 if (obj.edit_object.document.queryCommandState(cmd)) {
				element.className="wpLatchedOver"
				return
			}
		} catch (e) {
			element.className="wpOver"
			return
		}
	}
	element.className="wpOver"
}
// mouse out button style
function wp_m_out(element, obj) {
	if (obj.initfocus == false) {
		return
	}
	var cmd = element.getAttribute("cid")
	if (element.className=="wpDisabled") {
		return
	}
	if ((cmd=="edittable") || (cmd=="splitcell")) {
		cmd="inserthorizontalrule"
	}
	if (cmd == "border") {
		if (obj.border_visible) {
			element.className="wpLatched"
		} else {
			element.className="wpReady"
		}
		return
	} else if (cmd=="ignore") {
		element.className="wpReady"
		return	
	} else if ((cmd=="undo") ||  (cmd=="redo")) {
		element.className="wpReady"
		return
	} else {
		try {
			if (!obj.edit_object.document.queryCommandEnabled(cmd)) {
				element.className="wpDisabled"
				return
			} else if (obj.edit_object.document.queryCommandState(cmd)) {
				element.className="wpLatched"
				return
			}
		} catch (e) {	
			element.className="wpReady"
			return
		}
	}
	element.className="wpReady"
}
// mouse down button style
function wp_m_down(element, obj) {
	wp_closePopup();
	if (obj.initfocus == false) {
		obj.edit_object.focus();
		obj.initfocus = true;
	}
	if (element.className == "wpDisabled") {
		return
	}
	element.className="wpDown"
}
// mouse up button style
function wp_m_up(element, obj) {
	var style=element.className
	if (style=="wpDisabled") {
		return
	} else {
		if (style=="wpLatched") {
			return
		}
	}
	element.className="wpOver"
}
///////////////////////
// Set button states //
///////////////////////
// This changes the states of buttons everytime the selection changes, so that buttons that cannot be used based on the current user selection appear disabled.
// this is the crappiest slowest function in zeusedit, it really needs an overhaul!!
function wp_set_button_states(obj) {
	obj.initfocus = true
	var imageSelected = false
	var range = obj.edit_object.getSelection().getRangeAt(0)
	var container = range.startContainer
	var pos = range.startOffset
	var canLink = true
	var inside_link = wp_isInside(obj, 'A')
	if (range == '' && container.nodeType != 1 && !inside_link) {
		canLink = false
	}
	var imageNode = null
	if (container.tagName) {
		var images = container.getElementsByTagName('IMG');
		var cn = container.childNodes
		if (cn[pos]) {
			if (cn[pos].tagName == 'IMG') {
				imageNode = cn[pos]
			}
		}
	}
	if (imageNode) {
		imageSelected = true
	}
	var inside_table = wp_isInside(obj, 'TD')
	if (inside_table) {
		var wp_thisCell = container.parentNode
		while(wp_thisCell.tagName!="TD"&&wp_thisCell.tagName!="HTML") {
			wp_thisCell = wp_thisCell.parentNode
		}
	}	
	// evalute and set the toolbar button states
	for(var i = 0; i < obj.tbarlength; i++) {
		var pbtn = obj.tbarimages[i]
		var type = pbtn.getAttribute("type")
		if (type) {
			var cmd = pbtn.getAttribute("cid")
			if ((cmd=="edittable") || (cmd == 'splitcell')) {
			// table editing buttons
				if (inside_table) {
					if (cmd == 'splitcell') {
						if ((wp_thisCell.rowSpan >= 2) || (wp_thisCell.colSpan >=2)) {
							pbtn.className="wpReady"
						} else {
							pbtn.className="wpDisabled"
						}
					} else {
						pbtn.className="wpReady"
					}
				} else {
					pbtn.className="wpDisabled"
				}
			} else if (cmd=="createlink") {
				if (canLink) {
					pbtn.className="wpReady"
				} else {
					pbtn.className="wpDisabled"
				}
			} else if ((cmd=="undo") ||  (cmd=="redo")) {
					pbtn.className="wpReady"
			} else {
				try {
					if (obj.edit_object.document.queryCommandState(cmd)) {
						pbtn.className="wpLatched"
					} else if (!obj.edit_object.document.queryCommandEnabled(cmd)) {
						pbtn.className="wpDisabled"
					} else {	
						pbtn.className="wpReady"
					}
				} catch (e) {	
					pbtn.className="wpReady"
				}
			}
		}
	}
	var font_face_value = obj.edit_object.document.queryCommandValue('FontName')
	var font_size_value = obj.edit_object.document.queryCommandValue('FontSize')
	var format_list_value = obj.edit_object.document.queryCommandValue('FormatBlock')
	format_list_value = translate_format(format_list_value) 
	if (imageSelected) {
		var class_menu_value = ''
	} else {
		var foo = container.parentNode
		if (foo.tagName) {
			while(!foo.className&&foo.tagName!="BODY"&&foo.tagName!="HTML"&&foo.tagName) {
				foo = foo.parentNode
			}
			var class_menu_value = foo.className
		} else {
			var class_menu_value = ''
		}
	}
	wp_set_list_text ('font-face', font_face_value, 'font', obj)
	wp_set_list_text ('font_size', font_size_value, 'size', obj)
	wp_set_list_text ('format_list', format_list_value, 'format', obj)
	var class_menu_text = document.getElementById(obj.name+'_class_menu-text')
	if (class_menu_value) {
		if (class_menu_value == "wp_none") {
			if (class_menu_text.innerHTML != obj.lng['class'])
				class_menu_text.innerHTML = obj.lng['class']
		} else if (class_menu_text.innerHTML != class_menu_value) {
			class_menu_text.innerHTML = class_menu_value
		}
	} else {
		if (class_menu_text.innerHTML != obj.lng['class'])
			class_menu_text.innerHTML = obj.lng['class']
	}
}
function wp_set_list_text (list, value, lang, obj) {
	var list_text = document.getElementById(obj.name+'_'+list+'-text')
	if (value) {
		if (list_text.innerHTML != value)
			list_text.innerHTML = value
	} else {
		if (list_text.innerHTML != obj.lng[lang])
			list_text.innerHTML = obj.lng[lang]
	}
}
function translate_format(str) {
	if (wp_supported_blocks.test(str) ) {
		str = str.replace(/h([0-9])/gi, "Heading $1")
		str = str.replace(/\bp\b/gi, "Normal")
		str = str.replace(/div/gi, "Normal")
		str = str.replace(/pre/gi, "Formatted")
		str = str.replace(/address/gi, "Address")
	} else if (str == "x") {
		str = "Format"
	}
	return str
}

⌨️ 快捷键说明

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