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

📄 htmlarea.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
            f.__msh_prevOnReset.push(funcref);        }        f.onreset = function() {            editor.setHTML(editor._textArea.value);            editor.updateToolbar();            var a = this.__msh_prevOnReset;            // call previous reset methods if they were there.            if (typeof a != "undefined") {                for (var i = a.length; --i >= 0;) {                    a[i]();                }            }        };    }    // add a handler for the "back/forward" case -- on body.unload we save    // the HTML content into the original textarea.    try {    window.onunload = function() {        editor._textArea.value = editor.getHTML();    };    } catch(e) {};    // creates & appends the toolbar    this._createToolbar();    // create the IFRAME    var iframe = document.createElement("iframe");    iframe.src = "about:blank";    iframe.className = "iframe";    htmlarea.appendChild(iframe);    var editor = this    editor._iframe = iframe;    var doc = editor._iframe.contentWindow.document;    editor._doc = doc;    // Generate iframe content    var html = ""    if (!editor.config.fullPage) {        html = "<html>\n";        html += "<head>\n";        html += '<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n';        if (editor.config.baseURL)            html += '<base href="' + editor.config.baseURL + '" />';        html += '<style type="text/css">\n' + editor.config.pageStyle + "td { border: 1px dotted gray; } body { direction: <?php echo get_string('thisdirection')?>; } </style>\n"; // RTL support: direction added for RTL support        html += "</head>\n";        html += '<body>\n';        html += editor._textArea.value;        html = html.replace(/<nolink>/gi, '<span class="nolink">').                    replace(/<\/nolink>/gi, '</span>');        html += "</body>\n";        html += "</html>";    } else {        html = editor._textArea.value;        if (html.match(HTMLArea.RE_doctype)) {            editor.setDoctype(RegExp.$1);            html = html.replace(HTMLArea.RE_doctype, "");        }    }    // Write content to iframe    doc.open();    doc.write(html);    doc.close();    // The magic: onClick the designMode is set to 'on'    // This one is for click on HTMLarea toolbar and else    if(HTMLArea.is_gecko) {        HTMLArea._addEvents(          this._htmlArea,          ["mousedown"],          function(event) {            if(editor.designModeIsOn != true)            {                editor.designModeIsOn = true;                try {                  doc.designMode = "on";                } catch (e) {                  alert(e)                };            }          }        );        // This one is for click in iframe        HTMLArea._addEvents(          editor._iframe.contentWindow,          ["mousedown"],          function(event) {            if(editor.designModeIsOn != true)            {                editor.designModeIsOn = true;                try {                  doc.designMode = "on";                } catch (e) {                  alert(e)                };            }          }        );    }    // 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";    }    // size the IFRAME according to user's prefs or initial textarea    var height = (this.config.height == "auto" ? (this._ta_size.h) : this.config.height);    height = parseInt(height);    var width = (this.config.width == "auto" ? (this._toolbar.offsetWidth) : this.config.width);    width = (width == 0 ? 598 : width);    //width = Math.max(parseInt(width), 598);    width = String(width);    if (width.match(/^\d+$/)) { // is this a pure int? if so, let it be in px, and remove 2px        height -= 2;        width  -= 2;        width=width+"px";    }    iframe.style.width = width;    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;    if (HTMLArea.is_ie) {        doc.body.contentEditable = true;    }    // 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();        }        if (typeof plugin.onGenerateOnce == "function") {            plugin.onGenerateOnce();            plugin.onGenerateOnce = null;        }    }    // Moodle fix for bug Bug #2521 Too long statusbar line in IE    //    //setTimeout(function() {    //    editor.updateToolbar();    //}, 250);    if (typeof editor.onGenerate == "function") {        editor.onGenerate();    }};// 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) {            while(this._statusBar.childNodes.length>0) {                this._statusBar.removeChild(this._statusBar.childNodes[0]);            }            this._statusBar.appendChild(document.createTextNode(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(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: PLUGINSHTMLArea.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);};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() {    this._unnestBlocks();    var D = this.getInnerHTML();    if (/[Mm]so/.test(D)) {        // make one line        D = D.replace(/\r\n/g, '\[br\]').            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

⌨️ 快捷键说明

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