about some code of html editor

本文介绍了一个HTML编辑器的功能及其实现细节,包括如何在HTML与纯文本格式间进行转换,以及如何处理不同浏览器环境下的兼容性问题。此外,还涉及了编辑器中对于信纸、签名等功能的具体实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

LIKE THIS:

 

 

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>多媒体编辑器</title>


<style>
.hide{ display:none}
.divpic {display:inline;}
a.dm{text-decoration:none}
a.dm:hover{text-decoration:underline}
a{font-size:12px}
img{border:0}
td.icon{width:24px;height:24px;text-align:center;vertical-align:middle}
td.xz{width:47px;height:24px;text-align:center;vertical-align:middle}
td.bq{width:49px;height:24px;text-align:center;vertical-align:middle}
div a.n{height:16px;line-height:16px;display:block;padding:2px;color:#000000;text-decoration:none}
div a.n:hover{background:#E5E5E5}
.eMenu{position:absolute;background:#FFFFFF;border:1px solid #838383;padding:1px}
a.n1{height:16px;line-height:16px;display:block;padding:2px;color:#000000;text-decoration:none}
a.n1:hover{background:#E5E5E5}
a.cs{height:15px;position:relative}
*:lang(zh) a.cs{height:12px}
    .cs .cb{font-size:0;display:block;width:10px;height:8px;position:absolute;left:4px;top:3px;cursor:hand!important;cursor:pointer}
    .cs span{position:absolute;left:19px;top:0px;cursor:hand!important;cursor:pointer;color:#333}
   
    .fRd1 .cb{background-color:#800}
    .fRd2 .cb{background-color:#800080}
    .fRd3 .cb{background-color:#F00}
    .fRd4 .cb{background-color:#F0F}
    .fBu1 .cb{background-color:#000080}
    .fBu2 .cb{background-color:#00F}
    .fBu3 .cb{background-color:#0FF}
    .fGn1 .cb{background-color:#008080}
    .fGn2 .cb{background-color:#008000}
    .fGn3 .cb{background-color:#808000}
    .fGn4 .cb{background-color:#0F0}
    .fYl1 .cb{background-color:#FC0}
    .fBk1 .cb{background-color:#000}
    .fBk2 .cb{background-color:#808080}
    .fBk3 .cb{background-color:#C0C0C0}
    .fWt0 .cb{background-color:#FFF;border:1px solid #CCC}
   
#magicface td{height:29px;width:29px;background-color:#F8F8F8;text-align:center}
#magicface td onmouseover{background-Color:#FCC}
.mf_nowchose{height:30px;background-color:#DFDFDF;border:1px solid #B5B5B5;border-left:none}
.mf_other{height:30px;border-left:1px solid #B5B5B5}
.mf_otherdiv{height:30px;width:30px;border:1px solid #FFF;border-right-color:#D6D6D6;border-bottom-color:#D6D6D6;background-color:#F8F8F8}
.mf_otherdiv2{height:30px;width:30px;border:1px solid #B5B5B5;border-left:none;border-top:none}
.mf_link{font-size:12px;color:#000000;text-decoration:none}
.mf_link:hover{font-size:12px;color:#000000;text-decoration:underline}



.ico{height:24px;width:24px;vertical-align:middle;text-align:center}
.ico2{height:24px;width:27px;vertical-align:middle;text-align:center}
.ico3{height:24px;width:25px;vertical-align:middle;text-align:center}
.ico4{height:24px;width:8px;vertical-align:middle;text-align:center}
body{margin:0;padding:0}

.icons a,.edTb,.sepline,.sepline2,.switch,.tbri{background-image:url(images/mtoolallbg5.gif)}
/*.icons a,.edTb,.sepline,.sepline2,.switch,.tbri{background-image:url(mtoolallbg5.gif)}*/

.toobar{position:relative;height:29px;overflow:hidden}
    .tble{position:absolute;left:0;top:2px }
    *:lang(zh) .tble{top:2px}
    .tbri{width:120px;position:absolute;right:-3px;top:4px;background-position:0 -33px}
    *:lang(zh) .tbri{top:2px;background-position:0 -31px}
   
.toobarFull{position:relative;height:57px;overflow:hidden}
    .toobarFull .tble{ top:3px}

.icons a{width:23px;height:23px;background-repeat:no-repeat;display:block;float:left;margin-right:3px;border:1px solid #efefef;border-top:1px solid #F2F3F2;border-bottom:1px solid #F2F3F2}
*:lang(zh) .icons a{margin-right:1px}
.icons a:hover{border-top:1px solid #CCC;border-right:1px solid #999;border-bottom:1px solid #999;border-left:1px solid #CCC;background-color:#FFF}
a.icoCut{background-position:1px 2px;margin-right:2px}
a.icoCpy{background-position:-27px 1px;margin-right:2px}
a.icoPse{background-position:-55px 1px; width:50px}

a.icoFfm{background-position:-54px -95px;margin-right:1px; width:116px; height:20px; border:0; line-height:20px; padding-left:4px; text-decoration:none; color:#333; margin:2px 3px 0 1px}
a.icoFfm:hover{background-position:-54px -122px; border:0; color:#000}
a.icoFsz{background-position:-363px 1px}
   
a.icoWgt{background-position:-139px 0;margin-right:0}
    *:lang(zh) a.icoWgt{width:21px}
a.icoIta{background-position:-166px 0;margin-right:0}
    *:lang(zh) a.icoIta{width:21px}
a.icoUln{background-position:-196px 1px;margin-right:2px}
    *:lang(zh) a.icoUln{margin:0}
a.icoAgn{background-position:-224px 1px}
a.icoLst{background-position:-252px 1px}
a.icoOdt{background-position:-309px 1px}
a.icoIdt{background-position:-308px 1px}
a.icoFcl{background-position:-335px 1px}
a.icoBcl{background-position:-362px 1px}
a.icoUrl{background-position:-392px 1px;margin-right:0px}
a.icoImg{background-position:-419px 1px}
a.icoMfc{background-position:-447px 1px;width:24px}
a.icoLpr{background-position:-485px 0;width:80px}
a.icoSign{background-position:-532px 0;width:48px}
a.icoSwitchTxt{background-position:-594px 0px;width:46px;float:right}
a.icoSwitchMdi{background-position:-641px 0px;width:46px}
a.icoFullFnt{ background-position:-691px 0px; width:54px; float:right}
a.icoSimFnt{ background-position:-750px 0px; width:54px; float:right}
a.icoCode0{background-position:-827px -1px}
a.icoCode1{background-position:-865px -1px}

.tbri .sepline{ float:right; margin-left:-1px}

.edTb{border-bottom:1px solid #c5c5c5;border-top:1px solid #E1E1E1;background-position:0 -28px}
.sepline{width:4px;height:20px;margin-top:2px;margin-right:3px;background-position:-476px 0;background-repeat:no-repeat;float:left }
.sepline2{width:4px;height:50px;margin-top:2px;margin-right:3px;background-position:-6px -93px;background-repeat:no-repeat;float:left }

            .prt1{ float:left; position:relative; width:56px; height:57px}
                .prt1 a{ float:none; position:absolute}
                .prt1 .icoCut{ top:0; left:0}
                .prt1 .icoCpy{ top:0; left:27px}
                .prt1 .icoPse{ bottom:7px; left:0}
            .prt2{ float:left; position:relative; width:187px; height:57px; margin-left:2px}
                .prt2 a{ float:none;position:fixed;position:absolute}
                .prt2 .icoFfm{ top:0; left:0}
                .prt2 .icoFsz{ top:0; left:125px}
                .prt2  a.icoFsz{background-position:-199px -95px;margin-right:1px; width:51px; height:20px; border:0; line-height:20px; padding-left:4px; text-decoration:none; color:#333; margin:2px 3px 0 1px}
                .prt2  a.icoFsz:hover{background-position:-199px -122px; border:0; color:#000}               
                .prt2 .icoWgt{ bottom:7px; left:0}
                .prt2 .icoIta{ bottom:7px; left:24px}
                .prt2 .icoUln{ bottom:7px; left:48px}
                .prt2 .icoFcl{ bottom:7px; left:73px}
                .prt2 .icoAgn{ bottom:7px; left:102px}
                .prt2 .icoLst{ bottom:7px; left:128px}
                .prt2 .icoOdt{ bottom:7px; left:156px}
               
            .prt3{ float:left; position:relative; width:105px; height:57px}
                .prt3 a{ float:none; position:fixed;position:absolute}
                .prt3 .icoUrl{ top:0; left:3px}
                .prt3 .icoImg{ top:0; left:32px}
                .prt3 .icoMfc{ top:0; left:64px}
                .prt3 .icoLpr{ bottom:7px; left:0}
                .prt3 .icoSign{ bottom:7px; left:50px}
                .prt3 .icoVideo{ bottom:7px; left:80px}
           
            .prt4{ float:left; height:57px}
                .prt4 .icoCode0,.prt4 .icoCode1{ float:none; position:fixed;position:absolute; bottom:7px}
               
</style>

<SCRIPT LANGUAGE="JavaScript">
<!--
var MSG_INPUT_URL = "请输入正确的URL地址。";
var MSG_INVALID_FLASH = "只能选择SWF格式的文件,请重新选择。";
var MSG_INVALID_MEDIA = "只能选择MP3,WAV,WMA,WMV,MID,AVI,MPG,ASF格式的文件,请重新选择。";
var MSG_INVALID_REAL = "只能选择RM,RMVB格式的文件,请重新选择。";

var webPath ="";
function setWebPath(path){
 webPath = path;
}
function test(){
        var value;
        if(switchMode.checked){       
            $('switchMode').checked=(!$('switchMode').checked);
        }
        var f = window.frames["HtmlEditor"];
        value=  cleanWordChar(f.document.body.innerHTML);
       
        return value;
}


function test2(){
        var f = window.frames["HtmlEditor"];
        return f;
}

function setEditMode(){

    var f = window.frames["HtmlEditor"];
    if(f.document.designMode=="off")
        f.document.designMode="on";

}

function cleanWordChar(htmlContent){
    // Remove all SPAN tags
    htmlContent = htmlContent.replace(/<//?SPAN[^>]*>/gi, "");
    // Remove Class attributes
    htmlContent = htmlContent.replace(/<(/w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3") ;
    // Remove Style attributes
    htmlContent = htmlContent.replace(/<(/w[^>]*) style="([^"]*)"([^>]*)/gi,"<$1$3") ;
    // Remove Lang attributes
    htmlContent = htmlContent.replace(/<(/w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3") ;
    // Remove XML elements and declarations
    htmlContent = htmlContent.replace(/<//?/?xml[^>]*>/gi,"")  ;
    // Remove Tags with XML namespace declarations: <o:p></o:p>
    htmlContent = htmlContent.replace(/<//?/w+:[^>]*>/gi,"") ;
    // Replace the &nbsp;
    htmlContent = htmlContent.replace(/&nbsp;/," ");
    // Transform <P> to <DIV>
    var re = new RegExp("(<P)([^>]*>.*?)(<//P>)","gi") ;// Different because of a IE 5.0 error
    htmlContent = htmlContent.replace(re, "<div$2</div>") ;
    //insertHTML( HTML ) ;
    return htmlContent;
}

function getText(){
        var switchMode = $("switchMode");
        var HtmlEditor = window.frames["HtmlEditor"];
        var sourceEditor = $("sourceEditor");
        var value="";
        var htmlvalue="";
        if(switchMode.checked){
            htmlvalue = sourceEditor.value;
        }else{
            htmlvalue = HtmlEditor.document.body.innerHTML
        }
        if(htmlvalue.indexOf("img")>-1)return htmlvalue;
        if(switchMode.checked){
            value=  sourceEditor.value.unescapeHTML();
        }else{
            if(document.all){
                value=  HtmlEditor.document.body.innerText;
            }else{
                //value=  HtmlEditor.document.body.innerHTML.unescapeHTML();
                value=  HtmlEditor.document.body.textContent;
            }
        }
        //if(document.all){//for ie
            //return value.trim();
        //}else{//firefox
            //return value;
        //}
        return value.trim();
}

function setHtml(){
        //set html
        var parentValue = parent.window.eval("parentValue()");
        var f = window.frames["HtmlEditor"];
        f.document.body.innerHTML= parentValue;
}


function insertFile(){
    var webpathtmp= "../../";
    if(webPath != "")webpathtmp = webPath+"/";
    var splashWin = window.open (webpathtmp+'userfile-Server.html','newwindow','height=500,width=720,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no')

    splashWin.moveTo((parent.document.body.clientWidth-720)/2,(800-500)/2); 
    splashWin.focus();  
}



    function insertFormWin(html){
        alert("insertinto");
        var f = window.frames["HtmlEditor"];
        alert(f);
        //alert(html)
        f.document.body.innerHTML += html;
        //alert(f.document.body.innerHTML)
    }

    function fontname(obj){format('fontname',obj.innerHTML);obj.parentNode.style.display='none'}
    function fontsize(size,obj){format('fontsize',size);obj.parentNode.style.display='none'}

var gSetColorType = "";
var gIsIE = document.all;
var gIEVer = fGetIEVer();
var gLoaded = false;
var ev = null;
var gSigns = "";
var gSignHtml = "";

var gName = window.name;


/**
 * 获取event对象
 */
function fGetEv(e){
    ev = e;
}
/**
 * 设置domain属性
 */
function ResetDomain()
{   
    var f = window.frames["HtmlEditor"];
    var ss=document.domain;                        //ss == "www.126.com";
    var ii=ss.lastIndexOf('.');
    if(ii>0)
    {    if(!isNaN(ss.substr(ii+1)*1))
            return;
        ii=ss.lastIndexOf('.',ii-1);
        if(ii>0){
            f.document.domain = ss.substr(ii+1);
            document.domain    =ss.substr(ii+1);
        }
    }                                            //document.domain == "126.com";
}
/**
 * 获取IE版本
 */
function fGetIEVer(){
    var iVerNo = 0;
    var sVer = navigator.userAgent;
    if(sVer.indexOf("MSIE")>-1){
        var sVerNo = sVer.split(";")[1];
        sVerNo = sVerNo.replace("MSIE","");
        iVerNo = parseFloat(sVerNo);
    }
    return iVerNo;
}
/**
 * 设置可编辑
 */
function fSetEditable(){
    var f = window.frames["HtmlEditor"];
    f.document.designMode="on";
    if(!gIsIE)
        f.document.execCommand("useCSS",false, true);
}
/**
 * 设置编辑区域的事件
 */
function fSetFrmClick(){
    var f = window.frames["HtmlEditor"];
    f.document.onclick = function(){
        fHideMenu();
    }
    f.document.onkeydown = function(){
        parent.gIsEdited = true;
    }
}
/**
 * 设置onload事件
 */
window.onload = function(){
    if(gName == "ifrHtmlEditor") return;
    try{
        var f = window.frames["HtmlEditor"];
        var html = '<HEAD>' +
            '    <style>' +
            '    body{font-size:14px;font-family:/'宋体/'}' +
            '    pre,div,p {' +
            '    white-space: pre-wrap; /* css-3 */' +
            '    white-space: -moz-pre-wrap; /* Mozilla, since 1999 */' +
            '    white-space: -pre-wrap; /* Opera 4-6 */' +
            '    white-space: -o-pre-wrap; /* Opera 7 */' +
            '    word-wrap: break-word; /* Internet Explorer 5.5+ */' +
            '    /* white-space : normal ;       Internet Explorer 5.5+ */' +
            '    font-family:/'宋体/';' +
            '    }' +
            '    body{ margin:0; padding:8px 4px;}' +
            '    </style>' +
            '    </HEAD>' +
            '    <BODY>' +
            '    </BODY>';
        f.document.open("text/html","replace");
        f.document.write(html);
        f.document.close();
        f.document.designMode="on";
        if(!gIsIE)
            f.document.execCommand("useCSS",false, true);
    }catch(exp){}
    fixEditor = function(){
        try{
            parent.MM["compose"].fixEditor( window );
            // parent.hideEditorMenu = fHideMenu;
            parent.CC.hideMsg();
            // parent.EV.observe(parent.document, "click", fHideMenu);   
        }catch(exp){
            window.setTimeout("fixEditor()", 1000);
        }
    };
    try{
    fixEditor();
    }catch(exp){}
    gLoaded = true;
    // fSetEditable();
    try{
        fSetFrmClick();
    }catch(exp){}

}
/**
 * 设置文字颜色
 */
function fSetColor(){
    var dvForeColor =$("dvForeColor");
    if(dvForeColor.getElementsByTagName("TABLE").length == 1){
        dvForeColor.innerHTML = drawCube() + dvForeColor.innerHTML;
    }
}
/**
 * 设置mousemove事件
 */
document.onmousemove = function(e){
    if(gIsIE) var el = event.srcElement;
    else var el = e.target;
    var tdView = $("tdView");
    var tdColorCode = $("tdColorCode");

    if(el.tagName == "IMG"){
        try{
            if(fInObj(el, "dvForeColor")){
                tdView.bgColor = el.parentNode.bgColor;
                tdColorCode.innerHTML = el.parentNode.bgColor
            }
        }catch(e){}
    }
    if(el.tagName == "embed"){
        try{
            if(fInObj(el, "dvForeColor")){
                tdView.bgColor = el.parentNode.bgColor;
                tdColorCode.innerHTML = el.parentNode.bgColor
            }
        }catch(e){}
    }
}
/**
 * 判断el对象是否在另一个节点里
 */
function fInObj(el, id){
    if(el){
        if(el.id == id){
            return true;
        }else{
            if(el.parentNode){
                return fInObj(el.parentNode, id);
            }else{
                return false;
            }
        }
    }
}
/**
 * 显示对象
 */
function fDisplayObj(id){
    var o = $(id);
    if(o) o.style.display = "";
}
/**
 * 设置onclick事件
 */
document.onclick = function(e){
    if(gIsIE) var el = event.srcElement;
    else var el = e.target;
    var dvForeColor =$("dvForeColor");
    var dvPortrait =$("dvPortrait");

    if(el.tagName == "IMG"){
   
        try{
            if(fInObj(el, "dvForeColor")){
                format(gSetColorType, el.parentNode.bgColor);
                dvForeColor.style.display = "none";
                return;
            }
        }catch(e){}
        try{
            if(fInObj(el, "dvPortrait")){
                format("InsertImage", el.src);
                dvPortrait.style.display = "none";
                return;
            }
        }catch(e){}
    }
   
    fHideMenu();
    var hideId = "";
    if(el.id == "aGetSysSignList"){
        hideId = "dvSignList";
        parent.$(hideId).style.display = "";
    }else if(el.id == "imgStationery"){
        try{
            parent.LetterPaper.control(window, "show");
        }catch(exp){}
    }else if(arrMatch[el.id]){
        hideId = arrMatch[el.id];
        fDisplayObj(hideId);
    }
}
var arrMatch = {
    imgFontface:"fontface",
    imgFontsize:"fontsize",
    imgFontColor:"dvForeColor",
    imgBackColor:"dvForeColor",
    imgFace:"dvPortrait",
    imgAlign:"divAlign",
    imgList:"divList",
    imgSign:"dvSign",
    aGetSysSignList:"dvSignList",
    imgInOut:"divInOut"
}
/**
 * 执行格式化显示
 */
function format(type, para){
    var f = window.frames["HtmlEditor"];
        var sAlert = "";
    if(!gIsIE){
        switch(type){
            case "Cut":
                sAlert = "您的浏览器安全设置不允许编辑器自动执行剪切操作,请使用键盘快捷键(Ctrl+X)来完成";
                break;
            case "Copy":
                sAlert = "您的浏览器安全设置不允许编辑器自动执行拷贝操作,请使用键盘快捷键(Ctrl+C)来完成";
                break;
            case "Paste":
                sAlert = "您的浏览器安全设置不允许编辑器自动执行粘贴操作,请使用键盘快捷键(Ctrl+V)来完成";
                break;
        }
    }
    if(sAlert != ""){
        alert(sAlert);
        return;
    }
    f.focus();
    if(!para){
        if(gIsIE){
            f.document.execCommand(type);
        }else{
            f.document.execCommand(type,false,false);
        }
    }else{
            f.document.execCommand(type,false,para);
    }
    f.focus();
}
/**
 * 转换编辑模式
 */
function setMode(bStatus){
    var sourceEditor = $("sourceEditor");
    var HtmlEditor = $("HtmlEditor");
    var divEditor = $("divEditor");
    var f = window.frames["HtmlEditor"];
    var body = f.document.getElementsByTagName("BODY")[0];
    if(bStatus){
        sourceEditor.style.display = "";
        divEditor.style.display = "none";
        sourceEditor.value = body.innerHTML;
    }else{
        sourceEditor.style.display = "none";
        divEditor.style.display = "";
        body.innerHTML = sourceEditor.value;
    }

}


/**
 * 设置字体颜色
 */
function foreColor(e) {
    fDisplayColorBoard(e);
    gSetColorType = "foreColor";
}
/**
 * 设置背景色
 */
function backColor(e){
    var sColor = fDisplayColorBoard(e);
    if(gIsIE)
        gSetColorType = "backcolor";
    else
        gSetColorType = "backcolor";
}
/**
 * 显示颜色拾取器
 */
function fDisplayColorBoard(e){

    if(gIsIE){
        var e = window.event;
    }
    if(gIEVer<=5.01 && gIsIE){
        var arr = showModalDialog("ColorSelect.shtml", "", "font-family:Verdana; font-size:12; status:no; dialogWidth:21em; dialogHeight:21em");
        if (arr != null) return arr;
        return;
    }
    var dvForeColor =$("dvForeColor");
    // fSetColor();
    var iX = e.clientX;
    var iY = e.clientY;
    dvForeColor.style.display = "";
    dvForeColor.style.left = (iX-30) + "px";
    dvForeColor.style.top = gToolbarStatus?59 + "px":33 + "px";
    // EV.stopEvent();
    return true;
}
window.onerror = function(){return true;}
/**
 * 创建链接
 */
function createLink() {
    var sURL=window.prompt("请输入链接 (如:http://www.lansin.com/):", "http://");
    if ((sURL!=null) && (sURL!="http://")){
        format("CreateLink", sURL);
    }
}
/**
 * 创建图片
 */
function createImg()    {
    var sPhoto=prompt("请输入图片位置:", "http://");
    if ((sPhoto!=null) && (sPhoto!="http://")){
        format("InsertImage", sPhoto);
    }
}
/**
*auto ftao
*date 2008-06-05
*创建视频
*/
function createVideo(){
    var sPhoto=prompt("请输入视频HTML代码:", "<object>....</object>");
    if(sPhoto.length == 0)
    {
    alert("请输入视频HTML代码");
    return false;
    }
    if (sPhoto!=null){
        insertFormWin(sPhoto);
    }
}
/**
*auto ftao
*date 2008-06-05
*取文件名
*/
function KindGetFileName(file, separator)
{
    var temp = file.split(separator);
    var len = temp.length;
    var fileName = temp[len-1];
    return fileName;
}

/**
*auto ftao
*date 2008-06-05
*取文件名后缀
*/

function KindGetFileExt(fileName)
{
    var temp = fileName.split(".");
    var len = temp.length;
    var fileExt = temp[len-1].toLowerCase();
    return fileExt;
}

/**
*auto ftao
*date 2008-06-05
*插入FlashHTML
*/
function KindGetFlashHtmlTag(url, width, height)

{
    var str = '<embed src="'+url+'" quality="high"' +
              'width="'+width+'" height="'+height+'"' +
              'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed>';
   
    return str;
}
/**
*auto ftao
*date 2008-06-05
*验证Flash格式
*/
function KindCheckFlashFileType(file, separator)
{
    if (file.match(/http:////.{3,}/) == null) {
        alert(MSG_INPUT_URL);
        return false;
    }
    var fileName = KindGetFileName(file, "/");
    var fileExt = KindGetFileExt(fileName);
    if (fileExt != 'swf') {
        alert(MSG_INVALID_FLASH);
        return false;
    }
    return true;
}

/**
*auto ftao
*date 2008-06-05
*创建Flash
*/
function createFlash()
{

    var url=prompt("请输入Flash的位置:", "http://");
    if (KindCheckFlashFileType(url, "/") == false) {
        return false;
    }
    flashurl = KindGetFlashHtmlTag(url,260,360);
    insertFormWin(flashurl);
}



/**
 * 添加表情
 */
function addPortrait(e){

    if(gIEVer<=5.01 && gIsIE || 1==1){
        // var imgurl = showModalDialog("portraitSelect.shtml","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:358px; dialogHeight:232px");
        // if (imgurl != null)    format("InsertImage", imgurl);
        var dvPortrait =$("dvPortrait");
        if(dvPortrait){
            dvPortrait.parentNode.removeChild(dvPortrait);
        }
        var div = document.createElement("DIV");
        div.style.position = "absolute";
        div.style.zIndex = "9";
        div.id = "dvPortrait";
        var iX = e.clientX;
        div.style.top = gToolbarStatus?59 + "px":33 + "px";
       
        div.style.left = (iX-180) + "px";
        div.innerHTML = '<iframe border=0 marginWidth=0 marginHeight=0 frameBorder=no style="width:358px;height:232px" src="portraitSelect.shtml">';
        document.body.appendChild(div);
        var dvPortrait = $("dvPortrait");
        dvPortrait.style.display = "";
        // EV.stopEvent();
        return;
    }
    var dvPortrait =$("dvPortrait");
    var tbPortrait = $("tbPortrait");
    var iX = e.clientX;
    var iY = e.clientY;
    dvPortrait.style.display = "";
    if(window.screen.width == 1024){
        dvPortrait.style.left = (iX-300) + "px";
    }else{
        if(gIsIE)
            dvPortrait.style.left = (iX-300) + "px";
        else
            dvPortrait.style.left = (iX-300) + "px";
    }
    dvPortrait.style.top = gToolbarStatus?59 + "px":33 + "px";
    dvPortrait.innerHTML = '<table width="100%" border="0" cellpadding="5" cellspacing="1" style="cursor:hand" bgcolor="black" ID="tbPortrait"><tr align="left" bgcolor="#f8f8f8" class="unnamed1" align="center" ID="trContent">'+ drawPortrats() +'</tr>    </table>';
}

/**
 * 删除字符串两边空格
 */
String.prototype.trim = function(){
    return this.replace(/(^/s*)|(/s*$)/g, "");
}
/**
 * 鼠标移上图标
 */
function fSetBorderMouseOver(obj) {
    obj.style.borderRight="1px solid #aaa";
    obj.style.borderBottom="1px solid #aaa";
    obj.style.borderTop="1px solid #fff";
    obj.style.borderLeft="1px solid #fff";
}
/**
 * 鼠标移出图标
 */
function fSetBorderMouseOut(obj) {
    obj.style.border="none";
}
/**
 * 鼠标按下图标
 */
function fSetBorderMouseDown(obj) {
    obj.style.borderRight="1px #F3F8FC solid";
    obj.style.borderBottom="1px #F3F8FC solid";
    obj.style.borderTop="1px #cccccc solid";
    obj.style.borderLeft="1px #cccccc solid";
}
/**
 * 显示下拉菜单
 */
function fDisplayElement(element,displayValue) {
    if(gIEVer<=5.01 && gIsIE){
        if(element == "fontface"){
            var sReturnValue = showModalDialog("FontFaceSelect.shtml","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:112px; dialogHeight:271px");;
            format("fontname",sReturnValue);
        }else if(element == "fontsize"){
            var sReturnValue = showModalDialog("FontSizeSelect.shtml","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:130px; dialogHeight:250px");;
            format("fontsize",sReturnValue);
        }else if(element == "divAlign"){
            var sReturnValue = showModalDialog("AlignSelect.shtml","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:40px; dialogHeight:45px");;
            format(sReturnValue);
        }else if(element == "divList"){
            var sReturnValue = showModalDialog("/a/f/js3/ListSelect.shtml","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:60px; dialogHeight:45px");;
            format(sReturnValue);
        }else if(element == "divInOut"){
            var sReturnValue = showModalDialog("/a/f/js3/InOutdent.shtml","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:60px; dialogHeight:45px");;
            format(sReturnValue);
        }

        return;
    }
    fHideMenu();
    if(element == "sign"){
        var dvSign = $("dvSign");
        if(dvSign){
            dvSign.style.display = "none";
            dvSign.parentNode.removeChild(dvSign);
        }
        var div = document.createElement("DIV");
        div.id = "dvSign";
        div.style.position = "absolute";
        div.innerHTML = '<div style="padding:1px;background:#FFFFFF; border:1px solid #838383; width:100px;"><span></span><div style="height:1px; font-size:1px; border-bottom:1px dotted #999; margin-bottom:1px"></div><span></span></div>';
        if(top.frames["index"]){
            var a = [];
           
            var f = function(i){
                parent.MM["compose"].setSign(i);
            };
            parent.GE.signAllInfo.each(function(i,o){
                a.push({
                    name:o.name,
                    value:i,
                    callback:f
                });
            });
            a.push({
                name:"个性签名"
            });
            a.push({
                name:"设置签名",
                callback:function(){
                    parent.MM.getModule("signature");
                }
            });

            var signList = a;
        }else{
            var signList = parent.GE.signs;
        }
        var html = "";
        for(var i=0;i<signList.length;i++){
            var a = document.createElement("A");
            a.className = "n";
            a.innerHTML = signList[i].name;
            a.style.cursor = document.all?"hand":"pointer";
            eval('a.onclick= function(){fHideMenu();signList['+ i +'].callback("'+ signList[i].value +'");}');
            if(i == signList.length-1 || i == signList.length-2){
                div.firstChild.lastChild.appendChild(a);
                if(i == signList.length-2){
                    a.onclick = fGetSignList;
                    a.id = "aGetSysSignList";
                }
            }else{
                div.firstChild.firstChild.appendChild(a);
            }
        }
        document.body.appendChild(div);
        element = "dvSign";
    }
    if ( typeof element == "string" )
        element = $(element);
    if (element == null) return;
    element.style.display = displayValue;
    if(gIsIE){
        var e = event;
        var target = e.srcElement;
    }else{
        var e = ev;
        var target = e.target;
    }
    var iX = f_GetX(target);
    element.style.display = "";
    element.style.left = (iX) + "px";
    element.style.top = gToolbarStatus?59 + "px":33 + "px";
    // EV.stopEvent();
    return true;
}
/**
 * 显示编辑源码提示
 */
function fSetModeTip(obj){
    var x = f_GetX(obj);
    var y = f_GetY(obj);
    var dvModeTip = $("dvModeTip");
    if(!dvModeTip){
        var dv = document.createElement("DIV");
        dv.style.position = "absolute";
        dv.style.top = gToolbarStatus?59 + "px":33 + "px";
        dv.style.left = (x-40) + "px";
        dv.style.zIndex = "999";
        dv.style.fontSize = "12px";
        dv.id = "dvModeTip";
        dv.style.padding = "2 2 0 2px";
        dv.style.border = "1px #000000 solid";
        dv.style.backgroundColor = "#FFFFCC";
        dv.style.height = "12px";
        dv.innerHTML = "编辑源码";
        document.body.appendChild(dv);
    }else{
        dvModeTip.style.display = "";
    }
}
/**
 * 隐藏编辑源码
 */
function fHideTip(){
    $("dvModeTip").style.display = "none";
}
/**
 * 获取对象的x坐标
 */
function f_GetX(e)
{
    var l=e.offsetLeft;
    while(e=e.offsetParent){               
        l+=e.offsetLeft;
    }
    return l;
}
/**
 * 获取对象的y坐标
 */
function f_GetY(e)
{
    var t=e.offsetTop;
    while(e=e.offsetParent){
        t+=e.offsetTop;
    }
    return t;
}
/**
 * 隐藏下拉菜单
 */
function fHideMenu(){
    try{
        var arr = ["fontface", "fontsize", "dvForeColor", "dvPortrait", "divAlign", "divList", "dvSign" ,"divInOut" ];
        for(var i=0;i<arr.length;i++){
            var obj = $(arr[i]);
            if(obj){
                obj.style.display = "none";
            }
        }
        try{
            parent.LetterPaper.control(window, "hide");
        }catch(exp){}
        var dvSignList = parent.$("dvSignList");
        if(dvSignList) dvSignList.style.display = "none";
    }catch(exp){}
}

/**
 * 获取对象
 */
function $(id){
    return document.getElementById(id);
}
/**
 * 隐藏对象
 */
function fHide(obj){
    obj.style.display="none";
}
gIsHtml = true;
/**
 * 切换编辑模式
 */
function changeEditType(flag, ev){
    gIsHtml = flag;
    try{
        var mod = parent.MM["compose"];
        mod.html = flag;
    }catch(exp){}
    try{
        var dvhtml = $("dvhtml");
        var dvtext = $("dvtext");
        var HtmlEditor = window.frames["HtmlEditor"];
        var ifmHtmlEditor = $("HtmlEditor");
        var sourceEditor = $("sourceEditor");
        var switchMode = $("switchMode");
        var sourceEditor = $("sourceEditor");
        var dvHtmlLnk = $("dvHtmlLnk");
        if(flag){
            dvhtml.style.display = "";
            dvtext.style.display = "none";
            dvHtmlLnk.style.display = "none";
            // setMode(false);
            if(switchMode.checked){
                sourceEditor.value = dvtext.value;
            }else{
                HtmlEditor.document.body.innerHTML = dvtext.value;
            }
        }else{
            function sub1(){
                dvhtml.style.display = "none";
                dvtext.style.display = "";
                dvHtmlLnk.style.display = "";
                if(switchMode.checked){
                    dvtext.value = sourceEditor.value.unescapeHTML();
                }else{
                    if(document.all){
                        dvtext.value = HtmlEditor.document.body.innerText;
                    }else{
                        dvtext.value = HtmlEditor.document.body.innerHTML.unescapeHTML();
                    }
                }
                parent.MM["compose"].setLetter(-2)
            }
            ev = ev || event;
            if(ev){
                parent.CC.showSysMsg("将此邮件转换为纯文本将会遗失某些格式。<br>您确定要继续吗?", function(){sub1();}, false, true);
            }
        }

    }catch(exp){
   
    }
}
/**
 * 添加信纸
 */
function addStationery(){
    try{
        parent.LetterPaper.control(window, "show");
    }catch(exp){}
}
/**
 * 删除标签符号
 */
String.prototype.stripTags = function(){
    return this.replace(/<//?[^>]+>/gi, '');
};
/**
 * 转换成文本格式
 * qhb 修改于08-08-02
 */
String.prototype.unescapeHTML = function(){
    var div = document.createElement('div');
    div.innerHTML = this.stripTags();
    return div.innerHTML;
    //return;
   
};
// document.oncontextmenu = function(){return false}
function fStringDecodeHTML(s){

    s = s.replace(/&lt;/gi,"<");
    s = s.replace(/&gt;/gi,">");
    s = s.replace(/&quot;/gi,"/"");
    s = s.replace(/&amp;/gi,"&");
    s = s.replace(/&nbsp;/gi," ");
    return s;
}
/**
 * 获取个性签名
 */
function fGetSignList(id){
    var doc = frames["signlist"].document;
    if(!doc.getElementsByTagName("XMP")[0]){
        var html = fStringDecodeHTML(doc.documentElement.innerHTML);
        doc.body.innerHTML = html;
    }
    var sSign = doc.getElementsByTagName("XMP")[0].innerHTML;
    var html = doc.getElementById("html").innerHTML;
    var sign = new Sign(sSign, 10, html, id);
    sign.show();
}
/**
 * 个性签名类
 */
function Sign(sSign, count, html, bindId){
    var _data;
    var _bindId = bindId;
    var _current = 0;
    var _count = -1;
    var _pageCount = -1;
    var _start = 0;
    var _html = "";
    var _div = null;
    var _content = null;
    var _doc = window.top.frames["index"].document;
    var _js = window.top.frames["index"];
    var _pageInterval = 3;
    this.init = fInit;
    this.show = fShowSign;
    this.goPage = fGoPage;
    this.goPrePage = fGoPrePage;
    this.goNextPage = fGoNextPage;
    this.getPages = fGetPages;
    this.$$ = $$;
    this.init();
    function fInit(){
        if(document.all){
            _data = sSign.replace(//"/g,"///"").split(//r/n/);
        }else{
            _data = sSign.replace(//"/g,"///"").split(//n/);
        }
        _count = _data.length;
        _pageCount = Math.ceil(_data.length/count);
        _html = html;
    }
    function fShowSign(){
        var dvSignList = $$("dvSignList");
        if(dvSignList){
            dvSignList.parentNode.removeChild(dvSignList);
        }
        _div = _doc.createElement("DIV");
        _div.style.position = "absolute";
        _div.style.top = "255px";
        _div.style.left = "320px";
        _div.style.zIndex = "99";
        _div.innerHTML = _html;
        _div.id = "dvSignList";
        _doc.body.appendChild(_div);
        _js.CC.setDragable($$("trSignListTitle"), _div);
        $$("trSignListTitle").onclick = function(){
            _js.EV.stopEvent();
        };
        _content = $$("dvSignListContent");
        $$("aPrePage").onclick = this.goPrePage;
        $$("aNextPage").onclick = this.goNextPage;

        this.goPage(0);
        callback = function(){_div.style.display = "";_js.CC.clickToHide(_div);}
        window.setTimeout('callback()', 500);
    }
    function fGoPrePage(){
        fGoPage(--_current);   
    }
    function fGoNextPage(){
        fGoPage(++_current);
    }
    function fGoPage(n){
        if(n<0 || n>_pageCount-1){
            return;
        }
        if(n == 0){
            $$("aPrePage").style.visibility = "hidden";
            $$("aNextPage").style.visibility = "visible";
        }else if(n == _pageCount-1){
            $$("aPrePage").style.visibility = "visible";
            $$("aNextPage").style.visibility = "hidden";
        }else{
            $$("aPrePage").style.visibility = "visible";
            $$("aNextPage").style.visibility = "visible";
        }
        _current = n;
        _start = n * count;
        _content.innerHTML = "";

        for(var i=_start;i<_start + _count;i++){
            if(_data[i]){
                var a = _doc.createElement("A");
                a.href = "javascript:fGoto()";
                if(_bindId == "" || !_bindId || typeof(_bindId) == "object"){
                    eval('a.onclick = function(){parent.MM["compose"].setSign("custom","'+ _data[i] +'");}');
                }else{
                    eval('a.onclick = function(){parent.frames[_bindId].frames["HtmlEditor"].document.body.innerHTML = "<div>'+ _data[i] +'</div>"}');
                }
                _content.appendChild(a);
                a.innerHTML = _data[i];
            }
        }
        fGetPages();
    }
    function fGetPages(){
        $$("pageList").innerHTML = "";
        var _startPage = 0;
        if(_current < _pageInterval){
            _startPage = 0;
        }else if(_current > _pageCount - 1 - _pageInterval){
            _startPage = _pageCount - 1 - _pageInterval * 2;
        }else{
            _startPage = _current - _pageInterval;
        }
        for(var i=0;i<_pageInterval*2+1;i++){
            if(_startPage + i<_pageCount){
                var _no = _startPage + i + 1;
                if(_startPage + i == _current){
                    var _font = _doc.createElement("FONT");
                    _font.innerHTML = _no;
                    _font.style.width = "18px";
                    _font.color = "red";
                    $$("pageList").appendChild(_font);
                }else{
                    var _a = _doc.createElement("A");
                    _a.innerHTML = _no;
                    _a.style.width = "18px";
                    _a.href = "#";
                    eval('_a.onclick = function(){fGoPage('+ (_no-1) +')}');
                    $$("pageList").appendChild(_a);
                }
            }
        }
    }
    function $$(id){
        return _doc.getElementById(id);
    }
}
var gToolbarStatus = 0;
function fToggleToolbar(){
    if($("dvToobar").className.indexOf("hide")>-1){
        $("dvToobar").className = $("dvToobar").className.replace(" hide", "");
        $("dvToobarFull").className += " hide";
        gToolbarStatus = 0;
    }else{
        $("dvToobarFull").className = $("dvToobarFull").className.replace(" hide", "");
        $("dvToobar").className += " hide";
        gToolbarStatus = 1;
    }
}

//-->
</SCRIPT>
</head>
<body lang="zh" style="overflow-y:hidden ">
<iframe src="signlist.shtml" name="signlist" style="height:0px;width:0px;border:0px;display:none;"></iframe>
<table cellpadding="0" cellspacing="0" width="100%" id="dvHtmlLnk"  style="display:none">
  <tr>
    <td height="31">
    <table width="100%"  border="0" cellpadding="0" cellspacing="0" class="edTb">
        <tr>
          <td height="31" style="padding-left:5px;">
        <!--纯文本状态工具栏-->
        <div class="toobar">
            <div class="icons tble">
                <a href="#" class="icoSwitchMdi" title="切换到多媒体" onClick="changeEditType(true);return false;"></a>
            </div>
        </div>
        </td></tr></table>
</td></tr></table>
<textarea id="dvtext" style="height:88%;width:100%;border:0px;display:none;border-top:0px;padding:7px 4px 8px 8px;font-size:14px;font-family:Arial, Helvetica, sans-serif;line-height:170%;white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;"></textarea>
<div >

<table cellpadding="0" cellspacing="0" width="100%" height="100%" id="dvhtml">
  <tr>
    <td height="31">
    <table width="100%"  border="0" cellpadding="0" cellspacing="0" class="edTb">
        <tr>
          <td height="31" style=" padding-left:3px">
         
        <!--0810 多媒体状态工具栏 简单模式-->
        <div class="toobar" id="dvToobar">
            <div class="icons tble">
                <a href="#" class="icoWgt"  onClick="format('Bold');return false;" title="加粗"></a>
                <a href="#" class="icoIta" title="斜体"  onClick="format('Italic');return false;"></a>
                <a href="#" class="icoUln"  onClick="format('Underline');return false;" title="下划线"></a>
                <a href="#" class="icoFsz"  id="imgFontsize" title="字号" onClick="fGetEv(event);fDisplayElement('fontsize','');return false;"></a>
                <a href="#" class="icoFcl"  title="字体颜色" onClick="foreColor(event);return false;" id="imgFontColor"></a>
                <div class="sepline"></div>
                <a href="#" class="icoUrl"  onClick="createLink();return false;" title="超链接"></a>
                <a href="#" class="icoImg"  onClick="createImg();return false;" title="增加图片"></a>
                <a href="#" class="icoMfc"  onClick="addPortrait(event);return false;" title="魔法表情" id="imgFace"></a>
                <a href="javascript:void(0)" class="icoLpr"  onClick="insertFile()" title="插入文件" id="imgStationery"></a>
                <a href="#" onClick="createVideo();return false;" title="插入视频HTML代码"><img src="images/media.gif" border="0"></a>
                <a href="#" onClick="createFlash();return false;" title="插入Flash"><img src="images/flash.gif" border="0"></a>
                <!-- <a href="#" class="icoSign"  onClick="fGetEv(event);fDisplayElement('sign','');return false;"  title="签名" id="imgSign"></a> -->
            </div>
            <div class="icons tbri">
                <!-- <a href="#" class="icoSwitchTxt" title="切换到纯文本" onClick="changeEditType(false, event);return false;"></a>-->
                <!-- <div class="sepline"></div>-->
                <a href="#" class="icoFullFnt" title="全部功能" onClick="fToggleToolbar();return false;"></a>
            </div>
        </div>
        <input type="checkbox" value="" name="switchMode" id="switchMode" style="float:left;margin-top:6px!important;margin-top:2px;display:none;" onClick="setMode(this.checked)" onMouseOver="fSetModeTip(this)" onMouseOut="fHideTip()"/>
       
        <!--0810 多媒体状态工具栏 全部模式-->
        <div class="toobarFull hide" id="dvToobarFull">
            <div class="icons tble">
                <div class="prt1">
                    <a href="#" class="icoCut" title="剪切" onClick="format('Cut');return false;"></a>
                    <a href="#" class="icoCpy" title="复制" onClick="format('Copy');return false;"></a>
                    <a href="#" class="icoPse" title="粘贴" onClick="format('Paste');return false;"></a>
                </div>
               
                <div class="sepline2"></div>
               
                <div class="prt2">
                    <a href="#" class="icoFfm" id="imgFontface" title="字体" onClick="fGetEv(event);fDisplayElement('fontface','');return false;">宋体</a>
                    <a href="#" class="icoFsz"  id="imgFontsize" title="字号" onClick="fGetEv(event);fDisplayElement('fontsize','');return false;">字号</a>
                    <a href="#" class="icoWgt"  onClick="format('Bold');return false;" title="加粗"></a>
                    <a href="#" class="icoIta" title="斜体"  onClick="format('Italic');return false;"></a>
                    <a href="#" class="icoUln"  onClick="format('Underline');return false;" title="下划线"></a>
                    <a href="#" class="icoFcl"  title="字体颜色" onClick="foreColor(event);return false;" id="imgFontColor"></a>
                    <a href="#" class="icoAgn"  id="imgAlign" onClick="fGetEv(event);fDisplayElement('divAlign','');return false;" title="对齐"></a>
                    <a href="#" class="icoLst"  id="imgList" onClick="fGetEv(event);fDisplayElement('divList','');return false;"title="编号"></a>
                    <a href="#" class="icoOdt"  id="imgInOut" onClick="fGetEv(event);fDisplayElement('divInOut','');return false;" title="缩进"></a>
                </div>
               
                <div class="sepline2"></div>
               
                <div class="prt3">
                    <a href="#" class="icoUrl"  onClick="createLink();return false;" title="超链接"></a>
                    <a href="#" class="icoImg"  onClick="createImg();return false;" title="增加图片"></a>
                    <a href="#" class="icoMfc"  onClick="addPortrait(event);return false;" title="魔法表情" id="imgFace"></a>
                    <a href="#" class="icoVideo" onClick="createVideo();return false;" title="插入视频HTML代码"><img src="images/media.gif" border="0"></a>
                    <a href="#" onClick="createFlash();return false;" title="插入Flash"><img src="images/flash.gif" border="0"></a>
                    <a href="javascript:void(0)" class="icoLpr"  onClick="alert('ff');insertFile()" title="插入文件" id="imgStationery"></a>
                   
                    <!-- <a href="#" class="icoSign"  onClick="fGetEv(event);fDisplayElement('sign','');return false;"  title="签名" id="imgSign"></a> -->
                </div>
               
               
                <div class="sepline2"></div>
               
                <!--0817-->
                <div style="float: left;" >
                    <a href="#" class="icoCode0"  title="编辑源码" onclick="$('switchMode').checked=(!$('switchMode').checked);$('switchMode').onclick();this.className=((this.className=='icoCode0')?'icoCode1':'icoCode0');return false;"></a>
                </div>
               
            </div>
            <div class="icons tbri">
                <!-- <a href="#" class="icoSwitchTxt" title="切换到纯文本" onClick="changeEditType(false, event);return false;"></a>-->
                <!-- <div class="sepline"></div>-->
                <a href="#" class="icoSimFnt" title="简单功能" onClick="fToggleToolbar();return false;"></a>
   
            </div>
           

           
        </div>
       
       
       
        <!--纯文本状态工具栏-->
        <div class="toobar" style="display:none" id="dvHtmlLnk">
            <div class="icons tble">
                <a href="#" class="icoSwitchMdi" title="切换到多媒体" onClick="changeEditType(true, event);return false;"></a>
            </div>
        </div>
       
       
        </td>
      </tr>
    </table>
    
      <div style="width:100px;height:100px;position:fixed;_position:absolute;display:none;top:-500px;left:-500px" ID="dvPortrait"></div>
      <div id="fontface" class="eMenu" style="z-index:99;display:none;top:35px;left:2px;width:110px;height:230px"><a href="javascript:void(0)" onClick="fontname(this)" class="n" style="font:normal 12px '宋体';">宋体</a><a href="javascript:void(0)" onClick="fontname(this)" class="n" style="font:normal 12px '黑体';">黑体</a><a href="javascript:void(0)" onClick="fontname(this)" class="n" style="font:normal 12px '楷体_GB2312';">楷体_GB2312</a><a href="javascript:void(0)" onClick="fontname(this)" class="n" style="font:normal 12px '隶书';">隶书</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px '幼圆';">幼圆</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px Arial;">Arial</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px 'Arial Narrow';">Arial Narrow</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px 'Arial Black';">Arial Black</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px 'Comic Sans MS';">Comic Sans MS</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px Courier;">Courier</a><a href="###" onClick="fontname(this)" class="n" style="font:normal 12px System;">System</a><a href="javascript:void(0)" onClick="fontname(this)" class="n" style="font:normal 12px 'Times New Roman';">Times New Roman</a></div>
     
      <div id="fontsize" class="eMenu" style="display:none;top:35px;left:26px;width:125px;height:170px">
          <a href="javascript:void(0)" onClick="fontsize(1,this)" class="n" style="font-size:xx-small;line-height:120%;">极小</a>
          <a href="javascript:void(0)" onClick="fontsize(2,this)" class="n" style="font-size:x-small;line-height:120%;">特小</a>
          <a href="javascript:void(0)" onClick="fontsize(3,this)" class="n" style="font-size:small;line-height:120%;">小</a>
          <a href="javascript:void(0)" onClick="fontsize(4,this)" class="n" style="font-size:medium;line-height:120%;">中</a>
          <a href="javascript:void(0)" onClick="fontsize(5,this)" class="n" style="font-size:large;line-height:120%;">大</a>
          <a href="javascript:void(0)" onClick="fontsize(6,this)" class="n" style="font-size:x-large;line-height:120%;height:25px">特大</a>
          <a href="javascript:void(0)" onClick="fontsize(7,this)" class="n" style="font-size:xx-large;line-height:140%;height:35px">极大</a>
      </div>
     
      <div id="divList" class="eMenu" style="display:none;top:35px;left:26px;width:60px;height:40px;"><a href="javascript:void(0)" onClick="format('Insertorderedlist');fHide(this.parentNode)" class="n">数字列表</a><a href="javascript:void(0)" onClick="format('Insertunorderedlist');fHide(this.parentNode)" class="n">符号列表</a></div>
      <div id="divAlign" class="eMenu" style="display:none;top:35px;left:26px;width:60px;height:60px;"><a href="javascript:void(0)" onClick="format('Justifyleft');fHide(this.parentNode)" class="n">左对齐</a><a href="javascript:void(0)" onClick="format('Justifycenter');fHide(this.parentNode)" class="n">居中对齐</a><a href="javascript:void(0)" onClick="format('Justifyright');fHide(this.parentNode)" class="n">右对齐</a></div>
      <div id="divInOut" class="eMenu" style="display:none;top:35px;left:26px;width:60px;height:40px;"><a href="javascript:void(0)" onClick="format('Indent');fHide(this.parentNode)" class="n">增加缩进</a><a href="javascript:void(0)" onClick="format('Outdent');fHide(this.parentNode)" class="n">减少缩进</a></div>
     
      <div id="dvForeColor" class="eMenu" style="display:none;top:35px;left:26px;width:90px;">
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#800000')" class="n cs fRd1"><b class="cb"></b><span>暗红色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#800080')" class="n cs fRd2"><b class="cb"></b><span>紫色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#F00000')" class="n cs fRd3"><b class="cb"></b><span>红色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#F000F0')" class="n cs fRd4"><b class="cb"></b><span>鲜粉色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#000080')" class="n cs fBu1"><b class="cb"></b><span>深蓝色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#0000F0')" class="n cs fBu2"><b class="cb"></b><span>蓝色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#00F0F0')" class="n cs fBu3"><b class="cb"></b><span>湖蓝色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#008080')" class="n cs fGn1"><b class="cb"></b><span>蓝绿色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#008000')" class="n cs fGn2"><b class="cb"></b><span>绿色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#808000')" class="n cs fGn3"><b class="cb"></b><span>橄榄色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#00F000')" class="n cs fGn4"><b class="cb"></b><span>浅绿色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#F0C000')" class="n cs fYl1"><b class="cb"></b><span>橙黄色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#000000')" class="n cs fBk1"><b class="cb"></b><span>黑色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#808080')" class="n cs fBk2"><b class="cb"></b><span>灰色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#C0C0C0')" class="n cs fBk3"><b class="cb"></b><span>银色</span></a>
          <a href="javascript:void(0)" onClick="format(gSetColorType,'#FFFFFF')" class="n cs fWt0"><b class="cb"></b><span>白色</span></a>
      </div>
    
      <!--02-17 新加divSign,签名下拉菜单-->
   
    </td></tr>     
    <tr><td>
      <table cellpadding="0" cellspacing="0" style=" background-color:#999999;height:100%;width:100%;overflow:hidden">
        <tr>
          <td><SCRIPT LANGUAGE="JavaScript">
<!--
if(document.all){document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"  id="divEditor"><tr><td style=""><IFRAME class="HtmlEditor" ID="HtmlEditor" name="HtmlEditor" style="height:100%;width:100%" frameBorder="0" marginHeight=0 marginWidth=0 src="about:blank"></IFRAME></td></tr></table>')}else{document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"  id="divEditor"><tr><td style="background-color:#ffffff"><IFRAME class="HtmlEditor" ID="HtmlEditor" name="HtmlEditor" style="height:100%;width:100%;margin-left:1px;margin-bottom:1px;" frameBorder="0" marginHeight=0 marginWidth=0 src="about:blank"></IFRAME></td></tr></table>')}
//-->
</SCRIPT>
<textarea id="sourceEditor" style="height:100%;width:100%;display:none;border:0px;white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word;""></textarea>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</div>

</body>
</html>

Write java code: Copy the files, small_weapons.txt, and large_weapons.txt from the assignment folder on Blackboard and save them to your folder. For testing purposes, you should use the small file. Use the large file when you think the application works correctly. To see what is in the files use a text editor. Nilesh is currently enjoying the action RPG game Torchlight 2 which is an awesome game and totally blows Auction House Simulator 3, oh sorry, that should be Diablo 3, out of the water. He has got a file containing info on some of the unique weapons in the game. The transaction file contains the following information: Weapon Name (string) Weapon Type (string) Damage (int) Weapon Speed (double) … To tell if one weapon is better than another you need to know the Damage Per Second (DPS) the weapon does, since weapons have a different attack speed. DPS is calculated by taking the damage value and dividing it by the attack speed.a) You will write a program that will allow Nilesh to load the file and display the weapon info and DPS of every weapon in the input file. When the user chooses to open a weapon file, they are required to type in the filename. It will then read the 4 values about a particular weapon and then display the 4 values to the console window on one line neatly padded along with the DPS of the weapon. This is repeated until the end of the file. b) Modify your code from a) so that the weapon information written to the console window is also written to a text file. The user should be able to specify the name of the file. Add a header to the beginning of the file which has column headers for each column. At the end of the text file display the total number of weapons in the file. c) Document your code appropriately and add your name and id number as comments at the top of your code. Please also submit this text file you have created. Enter the file you want to search end with .txt: large_weapons.txt 1 Blackfang Bludgeon Great Hammer 489 1.44 339.58333333333337 2 Bones 2 Boneshredder Great Axe 256 0.84 304.76190476190476 3 Comet's Tail Great Sword 872 1.2 726.6666666666667 4 Decapitator Great Sword 188 1.08 174.07407407407408 5 Demolisher Great Hammer 887 1.32 671.9696969696969
05-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值