?? mozscript.js
字號(hào):
var n = attribute_array.length
for (i=0; i<n; i++) {
if (attribute_array[i].search("=") != -1) {
var attribute = attribute_array[i].split("=")
var elm = attribute[0].trim().replace(/"/gi,'')
var val = attribute[1].trim().replace(/"/gi,'')
bodytag[0].setAttribute( elm, val, 0 )
}
}
}
// end 222
if (headsplit.length>1) {
var head2 = headsplit[1].split(/<\/head>/gi)
head = head2[0]
}
if (bodysplit.length>1) {
var body2 = bodysplit[1].split(/<\/body>/gi)
bodyc = body2[0]
}
obj.edit_object.document.body.innerHTML = bodyc
// head contents
var headtag = obj.edit_object.document.getElementsByTagName('HEAD')
var headcontent = obj.baseURL;
if (obj.stylesheet != '') {
var num = obj.stylesheet.length;
for (var i=0; i < num; i++) {
headcontent += '<link rel="stylesheet" href="'+obj.stylesheet[i]+'" type="text/css">'
}
}
headcontent += head
headtag[0].innerHTML = headcontent
} else {
var headtag = obj.edit_object.document.getElementsByTagName('HEAD')
var headcontent = obj.charset + obj.baseURL
if (obj.stylesheet != '') {
var num = obj.stylesheet.length;
for (var i=0; i < num; i++) {
headcontent += '<link rel="stylesheet" href="'+obj.stylesheet[i]+'" type="text/css">'
}
}
headtag[0].innerHTML = headcontent
obj.edit_object.document.body.innerHTML = obj.html_edit_area.value
}
if (obj.border_visible == 1) {
obj.edit_object.document.onload = wp_show_borders(obj)
} else {
obj.edit_object.document.onload = wp_hide_borders(obj)
}
obj.styles = wp_make_styles (obj)
try {
obj.format_frame.written = false
obj.class_frame.written = false
obj.font_frame.written = false
obj.size_frame.written = false
} catch (e) {
}
if (obj.html_mode==false) {
try {
obj.edit_object.focus()
} catch (e) {
}
}
// wp 222
wp_font_hack(obj.edit_object.document.body, obj)
// wp 222
eval(obj.name+".edit_object.document.addEventListener('mouseup', wp_"+obj.name+"_mouseUpHandler, true)")
eval(obj.name+".edit_object.document.addEventListener('mousedown', wp_closePopup, true)")
eval(obj.name+".edit_object.document.addEventListener('keypress', wp_"+obj.name+"_keyHandler, true)")
eval(obj.name+".edit_object.document.addEventListener('contextmenu', wp_"+obj.name+"_contextHandler, true)")
if (init) {
wp_enable_designMode(obj)
}
document.getElementById(obj.name+'_load_message').style.display ='none'
}
// Catch and execute the commands sent from the buttons and tools
function wp_callFormatting(obj,sFormatString) {
obj.edit_object.focus()
if (sFormatString == "CreateLink") {
var szURL = prompt("Enter a URL:", "")
obj.edit_object.document.execCommand("CreateLink",false,szURL)
} else {
obj.edit_object.document.execCommand(sFormatString, false, null)
}
wp_set_button_states(obj)
}
function wp_change_class(obj,classname) {
wp_hide_menu(obj)
var sel = obj.edit_object.getSelection()
var range = sel.getRangeAt(0)
if (sel == '') {
return;
}
var container = range.startContainer
if (classname == 'wp_none') {
var foo = container.parentNode;
while(!foo.className&&foo.tagName!="BODY"&&foo.tagName!="HTML") {
foo = foo.parentNode;
}
if (foo.getAttribute('class') != 'wp_none' && foo.getAttribute('class') != '') {
foo.className = classname;
}
}
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)
obj.edit_object.focus()
}
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 + "hyperlink.php?target="+thisTarget+"&title="+thisTitle + "&lang="+obj.instance_lang
linkwin = obj.openDialog(szURL ,"modal",650,396)
}
}
// 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 + "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) {
var sel = obj.edit_object.getSelection()
var range = sel.getRangeAt(0)
var container = range.startContainer
if ((range == '') && (container.nodeType != 1) && (!wp_isInside(obj, 'A'))) {
alert(obj.lng['select_hyperlink_text'])
return
}
var thisTarget = ""
var thisTitle = ""
if (wp_isInside(obj, 'A')) {
var container = range.startContainer
if (container.nodeType != 1) {
var textNode = container
container = textNode.parentNode
}
thisA = container
while(thisA.tagName!="A"&&thisA.tagName!="BODY") {
thisA = thisA.parentNode
}
if (thisA.tagName == "A") {
var thisLink = thisA.getAttribute("HREF", 2)
wp_current_hyperlink = thisLink
if (thisA.getAttribute("target")) {
thisTarget = thisA.getAttribute("target")
}
if (thisA.getAttribute("title")) {
thisTitle = thisA.getAttribute("title")
}
} else {
wp_current_hyperlink = ''
}
} 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")
obj.edit_object.focus()
return
} else if(iHref=="mailto:") {
wp_callFormatting(obj, "Unlink")
obj.edit_object.focus()
return
} else {
var range = obj.edit_object.getSelection().getRangeAt(0)
var container = range.startContainer
var pos = range.startOffset
var imageNode = null
if (container.tagName) {
var images = container.getElementsByTagName('IMG');
var cn = container.childNodes
if (cn[pos]) {
if (cn[pos].tagName == 'IMG') {
cn[pos].setAttribute('border', 0);
}
}
}
if (wp_isInside(obj, 'A')) {
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
}
thisA = container
while(thisA.tagName!="A"&&thisA.tagName!="BODY") {
thisA = thisA.parentNode
}
if (thisA.tagName == "A") {
thisA.setAttribute('href',iHref)
thisA.setAttribute('target',iTarget)
thisA.setAttribute('title',iTitle)
}
} else {
obj.edit_object.document.execCommand("CreateLink",false,'WP_TEMP_LINK_'+iHref)
var links = obj.edit_object.document.getElementsByTagName('A')
var l=links.length
for (var i=0; i < l; i++) {
if (links[i].getAttribute('href')) {
if (links[i].getAttribute('href').search('WP_TEMP_LINK_') != -1) {
links[i].setAttribute('href',iHref)
if (iTitle != '') {
links[i].setAttribute('title',iTitle)
}
if (iTarget != '') {
links[i].setAttribute('target',iTarget)
}
var sel = obj.edit_object.getSelection()
var range = sel.getRangeAt(0)
sel.removeAllRanges()
}
}
}
}
}
obj.edit_object.focus()
}
// insert image
function wp_open_image_window(obj) {
var szURL
var range = obj.edit_object.getSelection().getRangeAt(0)
var container = range.startContainer
var pos = range.startOffset
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) {
if ((imageNode.getAttribute('name')) && (imageNode.src.search(wp_directory+"/images/bookmark_symbol.gif") != -1)) {
szURL= wp_directory + obj.imagewindow + "?lang="+obj.instance_lang
} else {
var str = ''
var image = imageNode.getAttribute('src', 2)
if (imageNode.style.height) {
str = imageNode.style.height
var height = str.replace(/px/, '')
} else {
var height = imageNode.getAttribute('height')
}
if (imageNode.style.width) {
str = imageNode.style.width
var width = str.replace(/px/, '')
} else {
var width = imageNode.getAttribute('width')
}
var alt = imageNode.getAttribute('alt')
var align = imageNode.getAttribute('align')
var mtop = imageNode.style.marginTop
var mbottom = imageNode.style.marginBottom
var mleft = imageNode.style.marginLeft
var mright = imageNode.style.marginRight
var iborder = imageNode.getAttribute('border')
szURL= wp_directory + 'imageoptions.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
}
} else {
szURL= 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()
img = obj.edit_object.document.createElement("img")
img.setAttribute("src", iurl)
if ((iwidth != '') && (iheight!='') && (iwidth != 0) && (iheight!=0) && (iheight!=null)) {
img.setAttribute("width", iwidth)
img.setAttribute("height", iheight)
}
if ((ialign != '') && (ialign!=0) && (ialign!=null)) {
img.setAttribute("align", ialign)
}
if ((iborder != '') && (iborder!=null)) {
img.setAttribute("border", iborder)
}
img.setAttribute("alt", ialt)
img.setAttribute("title", ialt)
if ((imargin != '') && (imargin!=null)) {
img.setAttribute("style", 'margin:'+imargin)
}
//img.src=img.src
wp_insertNodeAtSelection(obj.edit_object, img)
imgwin.close()
obj.edit_object.focus()
}
// create the horizontal rule html
function wp_create_hr(obj,align, color, size, width,percent2) {
obj.edit_object.focus()
hr = obj.edit_object.document.createElement("hr")
if (align!='') {
hr.setAttribute("align", align)
}
if (color != "") {
hr.setAttribute("color", color)
hr.style.backgroundColor = color
hr.setAttribute("noshade", "noshade")
}
if (size != "") {
hr.setAttribute("size", size)
}
if (width != "") {
hr.setAttribute("width", width+percent2)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -