Your IP : 216.73.216.34


Current Path : /home/zqegovsj/www/us3web.haibo.com.cn/biguo/image/js/
Upload File :
Current File : /home/zqegovsj/www/us3web.haibo.com.cn/biguo/image/js/votablefck.js

function markShow(){
    try {
        if (FCKeditorAPI &&
        document.getElementById('pTable').className != "exp") {
            document.getElementById('pTable').className = "exp";
            document.getElementById('prodTable___Frame').focus();
            FCKeditorAPI.GetInstance('product.prodTable').Focus();
            document.getElementById('pTable').style.display = ' ';
        }
        else {
            document.getElementById('pTable').className = "close";
        }
    } 
    catch (e) {
    }
}

var hasDone = false;
function FCKeditor_OnPaste(editorInstance){
    setTimeout(function(){
        if (hasDone) {
            hasDone = false;
            return true;
        }
        hasDone = true;
        document.getElementById('s15').disabled = true;
        var tmp = editorInstance.GetXHTML();
        if (jQuery.browser.safari) {
            tmp = '<table>' + tmp + '</table>';
        }
        var tmp2 = CleanTables(tmp);
        editorInstance.SetHTML(tmp2);
        editorInstance.ResetIsDirty();
        setTimeout(function(){
            document.getElementById('pTableTag').className = "collapsed";
            document.getElementById('s15').disabled = false;
        }, 500);
    }, 500);
    return true;
}

function FCKeditor_OnComplete(editorInstance){
    try {
        editorInstance.Events.AttachEvent('OnPaste', FCKeditor_OnPaste);
      //  editorInstance.Events.AttachEvent('OnBlur', FCKeditor_OnBlur);
        editorInstance.Events.AttachEvent('OnFocus', FCKeditor_OnFocus);
        editorInstance.Events.AttachEvent('OnAfterLinkedFieldUpdate', FCKeditor_OnSubmit);
    } 
    catch (e) {
    }
}

function FCKeditor_OnSubmit(editorInstance){
    var tableStr = CleanTables(editorInstance.GetHTML());
    setTimeout(function(){
        document.getElementById('pTableTag').className = "collapsed";
    }, 500);
    var fckTabName = document.getElementById('fckTabName').value;
    document.getElementById(fckTabName).value = tableStr;
}

function FCKeditor_OnBlur(editorInstance){
    var fckTabName = document.getElementById('fckTabName').value;
    editorInstance.SetHTML(cnToEn(editorInstance.GetHTML()));
    document.getElementById(fckTabName).value = editorInstance.GetHTML();
}

function FCKeditor_OnFocus(editorInstance){
    if (!document.all) {// Gecko stops editing when the FCK is hidden. --
        // Commented by Pierre Wu
        if (editorInstance.EditMode == FCK_EDITMODE_WYSIWYG) 
            editorInstance.MakeEditable();
    }
    if (editorInstance.IsDirty()) {
        document.getElementById('s15').disabled = true;
        if (!jQuery.browser.safari) {
            var text = CleanTables(editorInstance.GetHTML());
            editorInstance.SetHTML(text);
        }
        editorInstance.ResetIsDirty();
        setTimeout(function(){
            document.getElementById('pTableTag').className = "collapsed";
            document.getElementById('s15').disabled = false;
        }, 500);
    }
}

function CleanTables(html){
    document.getElementById('pTableTag').className = "expanded";
    try {
        html = html.replace(/<TABLE[^>]*?>/gi, '~!table!~');
        html = html.replace(/<\/TABLE>/gi, '~!/table!~');
        html = html.replace(/<TBODY[^>]*?>/gi, '~!tbody!~');
        html = html.replace(/<\/TBODY>/gi, '~!/tbody!~');
        html = html.replace(/<CAPTION[^>]*?>/gi, '~!caption!~');
        html = html.replace(/<\/CAPTION>/gi, '~!/caption!~');
        html = html.replace(/<TR[^>]*?>/gi, '~!tr!~');
        html = html.replace(/<\/TR>/gi, '~!/tr!~');
        html = html.replace(/<TH[^>]*?>/gi, '~!th!~');
        html = html.replace(/<\/TH>/gi, '~!/th!~');
        html = html.replace(/<TD[^>]*?(\bCOLSPAN="\d+")[^>]*?(\bROWSPAN="\d+")[^>]*?>/gi, '~!td $1 $2!~');
        html = html.replace(/<TD[^>]*?(\bROWSPAN="\d+")[^>]*?(\bCOLSPAN="\d+")[^>]*?>/gi, '~!td $2 $1!~');
        html = html.replace(/<TD[^>]*?(\bROWSPAN="\d+"|\bCOLSPAN="\d+")[^>]*?>/gi, '~!td $1!~');
        html = html.replace(/<TD[^>]*?>/gi, '~!td!~');
        html = html.replace(/<\/TD>/gi, '~!/td!~');
        html = html.replace(/<\/?P>/gi, '~!br!~');
        html = html.replace(/<SUB>(.*?)<\/SUB>/gi, '~!sub$1!~');
        html = html.replace(/<BR ?\/?>/gi, '~!br!~');
        html = html.replace(/<x:.*?>.*?<\/x:.*?>/g, ' ');//Word&Excel VML
        html = html.replace(/<o:.*?>.*?<\/o:.*?>/g, ' ');//Word&Excel VML
        html = html.replace(/<v:.*?>.*?<\/v:.*?>/g, ' ');//Word&Excel VML
        html = html.replace(/<[^>]*?>/g, ' ');
        html = html.replace(/\u3000/g, '&nbsp;');
        html = html.replace(/[\s]+/g, ' ');
        html = html.replace(/~!sub(.*?)!~/gi, '<sub>$1</sub>');
        html = html.replace(/~!br!~/gi, '<br />');
        html = html.replace(/~!\/td!~/gi, '</td>');
        html = html.replace(/~!td(.*?)!~/gi, '<td$1>');
        html = html.replace(/~!\/th!~/gi, '</th>');
        html = html.replace(/~!th!~/gi, '<th>');
        html = html.replace(/~!\/tr!~/gi, '</tr>');
        html = html.replace(/~!tr!~/gi, '<tr>');
        html = html.replace(/~!\/caption!~/gi, '</caption>');
        html = html.replace(/~!caption!~/gi, '<caption>');
        html = html.replace(/~!\/tbody!~/gi, '</tbody>');
        html = html.replace(/~!tbody!~/gi, '<tbody>');
        html = html.replace(/~!\/table!~/gi, '</table>');
        html = html.replace(/~!table!~/gi, '<table>');
        html = html.replace(/<td> *?([^ ]*?) *?<\/td>/gi, '<td>$1</td>');
        html = html.replace(/<td> +?<\/td>/gi, '<td>&nbsp;</td>');
        html = html.replace(/<th> *?([^ ]*?) *?<\/th>/gi, '<th>$1</th>');
        html = html.replace(/<th> +?<\/th>/gi, '<th>&nbsp;</th>');
        var iStartStr = html.indexOf('<table>');
        var iEndStr = html.lastIndexOf('</table>');
        html = html.substring(iStartStr > 0 ? iStartStr : 0, iEndStr > 0 ? iEndStr + 8 : 0);
    } 
    catch (e) {
        html = "";
    }
    return html;
}