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

📄 htmlarea.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
            replace(/<\/?personname[^>]*>/gi,'').            replace(/<\/?font[^>]*>/gi,'').    // Disable if you want to keep font formatting            replace(/<\/?span[^>]*>/gi,' ').            replace(/<\/?div[^>]*>/gi,' ').            replace(/<\/?pre[^>]*>/gi,' ').            replace(/<(\/?)(h[1-6]+)[^>]*>/gi,'<$1$2>');        // Lorenzo Nicola's addition        // to get rid off silly word generated tags.        D = D.replace(/<!--\[[^\]]*\]-->/gi,' ');        //remove empty tags        //D = D.replace(/<strong><\/strong>/gi,'').        //replace(/<i><\/i>/gi,'').        //replace(/<P[^>]*><\/P>/gi,'');        D = D.replace(/<h[1-6]+>\s?<\/h[1-6]+>/gi, ''); // Remove empty headings        // nuke double tags        oldlen = D.length + 1;        while(oldlen > D.length) {            oldlen = D.length;            // join us now and free the tags, we'll be free hackers, we'll be free... ;-)            D = D.replace(/<([a-z][a-z]*)> *<\/\1>/gi,' ').                replace(/<([a-z][a-z]*)> *<([a-z][^>]*)> *<\/\1>/gi,'<$2>');        }        D = D.replace(/<([a-z][a-z]*)><\1>/gi,'<$1>').            replace(/<\/([a-z][a-z]*)><\/\1>/gi,'<\/$1>');        // nuke double spaces        D = D.replace(/  */gi,' ');        // Split into lines and remove        // empty lines and add carriage returns back        var splitter  = /\[br\]/g;        var emptyLine = /^\s+\s+$/g;        var strHTML   = '';        var toLines   = D.split(splitter);        for (var i = 0; i < toLines.length; i++) {            var line = toLines[i];            if (line.length < 1) {                continue;            }            if (emptyLine.test(line)) {                continue;            }            line = line.replace(/^\s+\s+$/g, '');            strHTML += line + '\n';        }        D = strHTML;        strHTML = '';        this.setHTML(D);        this.updateToolbar();    }};HTMLArea.prototype._unnestBlockWalk = function(node, unnestingParent) {    if (HTMLArea.RE_blocktag.test(node.nodeName)) {	if (unnestingParent) {	    if (node.nextSibling) {		var splitNode = this._doc.createElement(unnestingParent.nodeName.toLowerCase());		while (node.nextSibling) {		    splitNode.appendChild(node.nextSibling);		}		unnestingParent.parentNode.insertBefore(splitNode, unnestingParent.nextSibling);	    }	    unnestingParent.parentNode.insertBefore(node, unnestingParent.nextSibling);	    return;	}	else if (node.firstChild) {	    this._unnestBlockWalk(node.firstChild, node);	}    } else {	if (node.firstChild) {	    this._unnestBlockWalk(node.firstChild, null);	}    }    if (node.nextSibling) {	this._unnestBlockWalk(node.nextSibling, unnestingParent);    }}HTMLArea.prototype._unnestBlocks = function() {    this._unnestBlockWalk(this._doc.documentElement, null);}HTMLArea.prototype.forceRedraw = function() {    this._doc.body.style.visibility = "hidden";    this._doc.body.style.visibility = "visible";    // this._doc.body.innerHTML = this.getInnerHTML();};// focuses the iframe window.  returns a reference to the editor document.HTMLArea.prototype.focusEditor = function() {    switch (this._editMode) {        case "wysiwyg" : this._iframe.contentWindow.focus(); break;        case "textmode": this._textArea.focus(); break;        default    : alert("ERROR: mode " + this._editMode + " is not defined");    }    return this._doc;};// takes a snapshot of the current text (for undo)HTMLArea.prototype._undoTakeSnapshot = function() {    ++this._undoPos;    if (this._undoPos >= this.config.undoSteps) {        // remove the first element        this._undoQueue.shift();        --this._undoPos;    }    // use the fasted method (getInnerHTML);    var take = true;    var txt = this.getInnerHTML();    if (this._undoPos > 0)        take = (this._undoQueue[this._undoPos - 1] != txt);    if (take) {        this._undoQueue[this._undoPos] = txt;    } else {        this._undoPos--;    }};HTMLArea.prototype.undo = function() {    if (this._undoPos > 0) {        var txt = this._undoQueue[--this._undoPos];        if (txt) this.setHTML(txt);        else ++this._undoPos;    }};HTMLArea.prototype.redo = function() {    if (this._undoPos < this._undoQueue.length - 1) {        var txt = this._undoQueue[++this._undoPos];        if (txt) this.setHTML(txt);        else --this._undoPos;    }};// updates enabled/disable/active state of the toolbar elementsHTMLArea.prototype.updateToolbar = function(noStatus) {    var doc = this._doc;    var text = (this._editMode == "textmode");    var ancestors = null;    if (!text) {        ancestors = this.getAllAncestors();        if (this.config.statusBar && !noStatus) {            while(this._statusBarTree.childNodes.length>0) {                this._statusBarTree.removeChild(this._statusBarTree.childNodes[0]);            }            this._statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"] + ": "));            for (var i = ancestors.length; --i >= 0;) {                var el = ancestors[i];                if (!el) {                    // hell knows why we get here; this                    // could be a classic example of why                    // it's good to check for conditions                    // that are impossible to happen ;-)                    continue;                }                var a = document.createElement("a");                a.href = "#";                a.el = el;                a.editor = this;                a.onclick = function() {                    this.blur();                    this.editor.selectNodeContents(this.el);                    this.editor.updateToolbar(true);                    return false;                };                a.oncontextmenu = function() {                    // TODO: add context menu here                    this.blur();                    var info = "Inline style:\n\n";                    info += this.el.style.cssText.split(/;\s*/).join(";\n");                    alert(info);                    return false;                };                var txt = el.tagName.toLowerCase();                a.title = el.style.cssText;                if (el.id) {                    txt += "#" + el.id;                }                if (el.className) {                    txt += "." + el.className;                }                a.appendChild(document.createTextNode(txt));                this._statusBarTree.appendChild(a);                if (i != 0) {                    this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb)));                }            }        }    }    for (var i in this._toolbarObjects) {        var btn = this._toolbarObjects[i];        var cmd = i;        var inContext = true;        if (btn.context && !text) {            inContext = false;            var context = btn.context;            var attrs = [];            if (/(.*)\[(.*?)\]/.test(context)) {                context = RegExp.$1;                attrs = RegExp.$2.split(",");            }            context = context.toLowerCase();            var match = (context == "*");            for (var k in ancestors) {                if (!ancestors[k]) {                    // the impossible really happens.                    continue;                }                if (match || (ancestors[k].tagName.toLowerCase() == context)) {                    inContext = true;                    for (var ka in attrs) {                        if (!eval("ancestors[k]." + attrs[ka])) {                            inContext = false;                            break;                        }                    }                    if (inContext) {                        break;                    }                }            }        }        btn.state("enabled", (!text || btn.text) && inContext);        if (typeof cmd == "function") {            continue;        }        // look-it-up in the custom dropdown boxes        var dropdown = this.config.customSelects[cmd];        if ((!text || btn.text) && (typeof dropdown != "undefined")) {            dropdown.refresh(this);            continue;        }        switch (cmd) {            case "fontname":            case "fontsize":            case "formatblock":                if (!text) try {                    var value = ("" + doc.queryCommandValue(cmd)).toLowerCase();                    if (!value) {                        // FIXME: what do we do here?                        break;                    }                    var options = this.config[cmd];                    var k = 0;                    // btn.element.selectedIndex = 0;                    for (var j in options) {                        // FIXME: the following line is scary.                        if ((j.toLowerCase() == value) ||                            (options[j].substr(0, value.length).toLowerCase() == value)) {                            btn.element.selectedIndex = k;                            break;                        }                        ++k;                    }                } catch(e) {};                break;            case "language":                if (!text) try {                    var value;                    parentEl = this.getParentElement();                    if (parentEl.getAttribute('lang')) {                        // A language was previously defined for the block.                        if (parentEl.getAttribute('class') == 'multilang') {                            value = parentEl.getAttribute('lang')+'_ML';                        } else {                            value = parentEl.getAttribute('lang');                        }                    } else {                        value = '';                    }                    var options = this.config[cmd];                    var k = 0;                    for (var j in options) {                        // FIXME: the following line is scary.                        if ((j.toLowerCase() == value) ||                            (options[j].substr(0, value.length).toLowerCase() == value)) {                            btn.element.selectedIndex = k;                            break;                        }                        ++k;                    }                } catch(e) {};                break;            case "textindicator":                if (!text) {                    try {with (btn.element.style) {                        backgroundColor = HTMLArea._makeColor(                            doc.queryCommandValue(HTMLArea.is_ie ? "backcolor" : "hilitecolor"));                        if (/transparent/i.test(backgroundColor)) {                            // Mozilla                            backgroundColor = HTMLArea._makeColor(doc.queryCommandValue("backcolor"));                        }                        color = HTMLArea._makeColor(doc.queryCommandValue("forecolor"));                        fontFamily = doc.queryCommandValue("fontname");                        fontWeight = doc.queryCommandState("bold") ? "bold" : "normal";                        fontStyle = doc.queryCommandState("italic") ? "italic" : "normal";                    }} catch (e) {                        // alert(e + "\n\n" + cmd);                    }                }                break;            case "htmlmode": btn.state("active", text); break;            case "lefttoright":            case "righttoleft":                var el = this.getParentElement();                while (el && !HTMLArea.isBlockElement(el))                    el = el.parentNode;                if (el)                    btn.state("active", (el.style.direction == ((cmd == "righttoleft") ? "rtl" : "ltr")));                break;            default:                try {                    btn.state("active", (!text && doc.queryCommandState(cmd)));                } catch (e) {}        }    }    // take undo snapshots    if (this._customUndo && !this._timerUndo) {        this._undoTakeSnapshot();        var editor = this;        this._timerUndo = setTimeout(function() {            editor._timerUndo = null;        }, this.config.undoTimeout);    }    // check if any plugins have registered refresh handlers    for (var i in this.plugins) {        var plugin = this.plugins[i].instance;        if (typeof plugin.onUpdateToolbar == "function")            plugin.onUpdateToolbar();    }};/** Returns a node after which we can insert other nodes, in the current * selection.  The selection is removed.  It splits a text node, if needed. */HTMLArea.prototype.insertNodeAtSelection = function(toBeInserted) {    if (!HTMLArea.is_ie) {        var sel = this._getSelection();

⌨️ 快捷键说明

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