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

📄 htmlarea_bak.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        f.onsubmit = function() {            editor._textArea.value = editor.getHTML();            var a = this.__msh_prevOnSubmit;            // call previous submit methods if they were there.            if (typeof a != "undefined") {                for (var i in a) {                    a[i]();                }            }        };    }    // add a handler for the "back/forward" case -- on body.unload we save    // the HTML content into the original textarea.    window.onunload = function() {        editor._textArea.value = editor.getHTML();    };    // creates & appends the toolbar    this._createToolbar();    // create the IFRAME    var iframe = document.createElement("iframe");    if (HTMLArea.is_ie) {  // http://moodle.org/mod/forum/discuss.php?d=8555        // tricky! set src to local url to turn off SSL security alert        iframe.src = _editor_url + this.config.popupURL+"blank.html";    }    htmlarea.appendChild(iframe);    this._iframe = iframe;    // creates & appends the status bar, if the case    this._createStatusBar();    // remove the default border as it keeps us from computing correctly    // the sizes.  (somebody tell me why doesn't this work in IE)    if (!HTMLArea.is_ie) {        iframe.style.borderWidth = "1px";    // iframe.frameBorder = "1";    // iframe.marginHeight = "0";    // iframe.marginWidth = "0";    }    // size the IFRAME according to user's prefs or initial textarea    var height = (this.config.height == "auto" ? (this._ta_size.h + "px") : this.config.height);    height = parseInt(height);    var width = (this.config.width == "auto" ? (this._ta_size.w + 50 + "px") : this.config.width);    width = parseInt(width);    if (!HTMLArea.is_ie) {        height -= 2;        width -= 2;    }    iframe.style.width = width + "px";    if (this.config.sizeIncludesToolbar) {        // substract toolbar height        height -= this._toolbar.offsetHeight;        height -= this._statusBar.offsetHeight;    }    if (height < 0) {        height = 0;    }    iframe.style.height = height + "px";    // the editor including the toolbar now have the same size as the    // original textarea.. which means that we need to reduce that a bit.    textarea.style.width = iframe.style.width;    textarea.style.height = iframe.style.height;    // IMPORTANT: we have to allow Mozilla a short time to recognize the    // new frame.  Otherwise we get a stupid exception.    function initIframe() {        var doc = editor._iframe.contentWindow.document;        if (!doc) {            // Try again..            // FIXME: don't know what else to do here.  Normally            // we'll never reach this point.            if (HTMLArea.is_gecko) {                setTimeout(initIframe, 100);                return false;            } else {                alert("ERROR: IFRAME can't be initialized.");            }        }        if (HTMLArea.is_gecko) {            // enable editable mode for Mozilla            doc.designMode = "on";        }        editor._doc = doc;        if (!editor.config.fullPage) {            doc.open();            var html = "<html>\n";            html += "<head>\n";            if (editor.config.baseURL)                html += '<base href="' + editor.config.baseURL + '" />';            html += "<style>" + editor.config.pageStyle + " td { border: 1px dotted gray; }</style>\n";            html += "</head>\n";            html += "<body>\n";            html += editor._textArea.value;            html += "</body>\n";            html += "</html>";            doc.write(html);            doc.close();        } else {            var html = editor._textArea.value;            if (html.match(HTMLArea.RE_doctype)) {                editor.setDoctype(RegExp.$1);                html = html.replace(HTMLArea.RE_doctype, "");            }            doc.open();            doc.write(html);            doc.close();        }        if (HTMLArea.is_ie) {            // enable editable mode for IE.  For some reason this            // doesn't work if done in the same place as for Gecko            // (above).            doc.body.contentEditable = true;        }        editor.focusEditor();        // intercept some events; for updating the toolbar & keyboard handlers        HTMLArea._addEvents            (doc, ["keydown", "keypress", "mousedown", "mouseup", "drag"],             function (event) {                 return editor._editorEvent(HTMLArea.is_ie ? editor._iframe.contentWindow.event : event);             });        // check if any plugins have registered refresh handlers        for (var i in editor.plugins) {            var plugin = editor.plugins[i].instance;            if (typeof plugin.onGenerate == "function")                plugin.onGenerate();        }        setTimeout(function() {        editor.updateToolbar();        }, 250);        if (typeof editor.onGenerate == "function")            editor.onGenerate();    };    setTimeout(initIframe, 100);};// Switches editor mode; parameter can be "textmode" or "wysiwyg".  If no// parameter was passed this function toggles between modes.HTMLArea.prototype.setMode = function(mode) {    if (typeof mode == "undefined") {        mode = ((this._editMode == "textmode") ? "wysiwyg" : "textmode");    }    switch (mode) {        case "textmode":        this._textArea.value = this.getHTML();        this._iframe.style.display = "none";        this._textArea.style.display = "block";        if (this.config.statusBar) {            this._statusBar.innerHTML = HTMLArea.I18N.msg["TEXT_MODE"];        }        break;        case "wysiwyg":        if (HTMLArea.is_gecko) {            // disable design mode before changing innerHTML            try {            this._doc.designMode = "off";            } catch(e) {};        }        if (!this.config.fullPage)            this._doc.body.innerHTML = this.getHTML();        else            this.setFullHTML(this.getHTML());        this._iframe.style.display = "block";        this._textArea.style.display = "none";        if (HTMLArea.is_gecko) {            // we need to refresh that info for Moz-1.3a            try {            this._doc.designMode = "on";            //this._doc.focus();            } catch(e) {};        }        if (this.config.statusBar) {            this._statusBar.innerHTML = '';            this._statusBar.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"] + ": "));            this._statusBar.appendChild(this._statusBarTree);        }        break;        default:        alert("Mode <" + mode + "> not defined!");        return false;    }    this._editMode = mode;    this.focusEditor();};HTMLArea.prototype.setFullHTML = function(html) {    var save_multiline = RegExp.multiline;    RegExp.multiline = true;    if (html.match(HTMLArea.RE_doctype)) {        this.setDoctype(RegExp.$1);        html = html.replace(HTMLArea.RE_doctype, "");    }    RegExp.multiline = save_multiline;    if (!HTMLArea.is_ie) {        if (html.match(HTMLArea.RE_head))            this._doc.getElementsByTagName("head")[0].innerHTML = RegExp.$1;        if (html.match(HTMLArea.RE_body))            this._doc.getElementsByTagName("body")[0].innerHTML = RegExp.$1;    } else {        var html_re = /<html>((.|\n)*?)<\/html>/i;        html = html.replace(html_re, "$1");        this._doc.open();        this._doc.write(html);        this._doc.close();        this._doc.body.contentEditable = true;        return true;    }};/*************************************************** *  Category: PLUGINS ***************************************************/// this is the variant of the function above where the plugin arguments are// already packed in an array.  Externally, it should be only used in the// full-screen editor code, in order to initialize plugins with the same// parameters as in the opener window.HTMLArea.prototype.registerPlugin2 = function(plugin, args) {    if (typeof plugin == "string")        plugin = eval(plugin);    var obj = new plugin(this, args);    if (obj) {        var clone = {};        var info = plugin._pluginInfo;        for (var i in info)            clone[i] = info[i];        clone.instance = obj;        clone.args = args;        this.plugins[plugin._pluginInfo.name] = clone;    } else        alert("Can't register plugin " + plugin.toString() + ".");};// Create the specified plugin and register it with this HTMLAreaHTMLArea.prototype.registerPlugin = function() {    var plugin = arguments[0];    var args = [];    for (var i = 1; i < arguments.length; ++i)        args.push(arguments[i]);    this.registerPlugin2(plugin, args);};// static function that loads the required plugin and lang file, based on the// language loaded already for HTMLArea.  You better make sure that the plugin// _has_ that language, otherwise shit might happen ;-)HTMLArea.loadPlugin = function(pluginName) {    var dir = _editor_url + "plugins/" + pluginName;    var plugin = pluginName.replace(/([a-z])([A-Z])([a-z])/g,                    function (str, l1, l2, l3) {                        return l1 + "-" + l2.toLowerCase() + l3;                    }).toLowerCase() + ".js";    var plugin_file = dir + "/" + plugin;    var plugin_lang = dir + "/lang/" + HTMLArea.I18N.lang + ".js";    HTMLArea._scripts.push(plugin_file, plugin_lang);    document.write("<script type='text/javascript' src='" + plugin_file + "'></script>");    document.write("<script type='text/javascript' src='" + plugin_lang + "'></script>");};HTMLArea.loadStyle = function(style, plugin) {    var url = _editor_url || '';    if (typeof plugin != "undefined") {        url += "plugins/" + plugin + "/";    }    url += style;    document.write("<style type='text/css'>@import url(" + url + ");</style>");};HTMLArea.loadStyle("htmlarea.css");/*************************************************** *  Category: EDITOR UTILITIES ***************************************************/// The following function is a slight variation of the word cleaner code posted// by Weeezl (user @ InteractiveTools forums).HTMLArea.prototype._wordClean = function() {    var D = this.getInnerHTML();    if (D.indexOf("class=Mso") >= 0 || D.indexOf("mso") >= 0 || D.indexOf("Mso") >= 0) {        // make one line        D = D.replace(/\r\n/g, ' ').            replace(/\n/g, ' ').            replace(/\r/g, ' ').            replace(/\&nbsp\;/g,' ');        // keep tags, strip attributes        D = D.replace(/ class=[^\s|>]*/gi,'').            //replace(/<p [^>]*TEXT-ALIGN: justify[^>]*>/gi,'<p align="justify">').            replace(/ style=\"[^>]*\"/gi,'').            replace(/ align=[^\s|>]*/gi,'');        //clean up tags        D = D.replace(/<b [^>]*>/gi,'<b>').            replace(/<i [^>]*>/gi,'<i>').            replace(/<li [^>]*>/gi,'<li>').            replace(/<ul [^>]*>/gi,'<ul>');        // replace outdated tags        D = D.replace(/<b>/gi,'<strong>').            replace(/<\/b>/gi,'</strong>');        // mozilla doesn't like <em> tags        D = D.replace(/<em>/gi,'<i>').            replace(/<\/em>/gi,'</i>');        // kill unwanted tags        D = D.replace(/<\?xml:[^>]*>/g, '').       // Word xml            replace(/<\/?st1:[^>]*>/g,'').     // Word SmartTags            replace(/<\/?[a-z]\:[^>]*>/g,'').  // All other funny Word non-HTML stuff            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>');        //remove empty tags        //D = D.replace(/<strong><\/strong>/gi,'').        //replace(/<i><\/i>/gi,'').        //replace(/<P[^>]*><\/P>/gi,'');        // 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,' ').

⌨️ 快捷键说明

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