📄 html_editor.js
字号:
// -----------------------------------------------------------------------// This file is part of AROUNDMe// // Copyright (C) 2003-2007 Barnraiser// http://www.barnraiser.org/// info@barnraiser.org// // This program is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; see the file COPYING.txt. If not, see// <http://www.gnu.org/licenses/>// -----------------------------------------------------------------------function preview(html_editor_name) { var str = "content=" + escape(document.getElementById(html_editor_name).value); makeRequest('components/core/relay/html_editor.php', str, view_preview); document.getElementById('preview').style.display = "block"; document.getElementById(html_editor_name).style.display = "none"; document.getElementById('tools').style.display = "none"; document.getElementById('_preview').className = "button active"; document.getElementById('_edit').className = "button";}function view_preview() { if (http_request.readyState == 4) { if (http_request.status == 200) { parent.frames[0].document.getElementById('body_container').innerHTML = ""; var result = http_request.responseText; parent.frames[0].document.getElementById('body_container').innerHTML = result; } }}function edit(html_editor_name) { document.getElementById('preview').style.display = "none"; document.getElementById(html_editor_name).style.display = "block"; document.getElementById('tools').style.display = "block"; document.getElementById('_preview').className = "button"; document.getElementById('_edit').className = "button active";}/*The following function was from the Dokuwiki project (also GPL):http://wiki.splitbrain.org/wiki:dokuwikiby Andreas Gohr <andi@splitbrain.org>Thank you to the docuwiki project for their contribution to this project!*/function insertTag(src,tagOpen,tagClose) { var txtarea = document.getElementById(src); // IE if(document.selection && !is_gecko) { var theSelection = document.selection.createRange().text; var replaced = true; if(!theSelection){ replaced = false; } txtarea.focus(); // This has change var text = theSelection; if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any theSelection = theSelection.substring(0, theSelection.length - 1); r = document.selection.createRange(); r.text = tagOpen + theSelection + tagClose + " "; } else { r = document.selection.createRange(); r.text = tagOpen + theSelection + tagClose; } if(!replaced){ r.moveStart('character',-text.length-tagClose.length); r.moveEnd('character',-tagClose.length); } r.select(); // Mozilla } else if(txtarea.selectionStart || txtarea.selectionStart == '0') { replaced = false; var startPos = txtarea.selectionStart; var endPos = txtarea.selectionEnd; if(endPos - startPos) { replaced = true; } var scrollTop=txtarea.scrollTop; var myText = (txtarea.value).substring(startPos, endPos); if(!myText) { myText=''; } if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; } else { subst = tagOpen + myText + tagClose; } txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length); txtarea.focus(); //set new selection if(replaced){ var cPos=startPos+(tagOpen.length+myText.length+tagClose.length); txtarea.selectionStart=cPos; txtarea.selectionEnd=cPos; }else{ txtarea.selectionStart=startPos+tagOpen.length; txtarea.selectionEnd=startPos+tagOpen.length+myText.length; } txtarea.scrollTop=scrollTop; // All others } else { var copy_alertText=alertText; var re1=new RegExp("\\$1","g"); var re2=new RegExp("\\$2","g"); copy_alertText=copy_alertText.replace(re1,''); copy_alertText=copy_alertText.replace(re2,tagOpen+tagClose); text=tagOpen+tagClose; //append to the end txtarea.value += "\n"; // in Safari this causes scrolling if(!is_safari) { txtarea.focus(); } } // reposition cursor if possible if (txtarea.createTextRange){ txtarea.caretPos = document.selection.createRange().duplicate(); }}// added by sebastianfunction fetchCss() { var style = document.createElement('style'); style.setAttribute('type', 'text/css'); if(style.styleSheet) { var styles = parent.frames[0].document.styleSheets; styles[0].cssText = styles[0].cssText + '\n' + webspace_css; } else { var text = document.createTextNode(webspace_css); style.appendChild(text); } parent.frames[0].document.getElementsByTagName('head').item(0).appendChild(style);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -