2002-10-10 07:21:32 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// HTML Text Editing Component for hosting in Web Pages
|
|
|
|
// Copyright (C) 2001 Ramesys (Contracting Services) Limited
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library 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
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU LesserGeneral Public License
|
|
|
|
// along with this program; if not a copy can be obtained from
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
//
|
|
|
|
// or by writing to:
|
|
|
|
//
|
|
|
|
// Free Software Foundation, Inc.
|
|
|
|
// 59 Temple Place - Suite 330,
|
|
|
|
// Boston,
|
|
|
|
// MA 02111-1307,
|
|
|
|
// USA.
|
|
|
|
//
|
|
|
|
// Original Developer:
|
|
|
|
//
|
|
|
|
// Austin David France
|
|
|
|
// Ramesys (Contracting Services) Limited
|
|
|
|
// Mentor House
|
|
|
|
// Ainsworth Street
|
|
|
|
// Blackburn
|
|
|
|
// Lancashire
|
|
|
|
// BB1 6AY
|
|
|
|
// United Kingdom
|
|
|
|
// email: Austin.France@Ramesys.com
|
|
|
|
//
|
|
|
|
// Home Page: http://richtext.sourceforge.net/
|
|
|
|
// Support: http://richtext.sourceforge.net/
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Author(s): leonreinders@hetnet.nl LEON
|
|
|
|
//
|
|
|
|
// Austin.France@Ramesys.com OZ
|
|
|
|
//
|
|
|
|
// History:
|
|
|
|
//
|
|
|
|
// LEON 04-08-2001
|
|
|
|
// Initial Implementation
|
|
|
|
//
|
|
|
|
// OZ Disable/enable post button during view source mode.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// setEditMode(): switch between html and textview
|
|
|
|
function setEditMode() {
|
|
|
|
switchMode.blur(); // htmlview
|
|
|
|
if (switchMode.checked == true) {
|
2002-10-12 03:54:56 +00:00
|
|
|
ctlStyle.disabled = ctlFont.disabled = ctlSize.disabled = true;
|
2002-10-10 07:21:32 +00:00
|
|
|
doc.style.fontFamily = "Courier";
|
|
|
|
doc.style.fontSize = "10px";
|
|
|
|
RichEditor.txtView = false;
|
|
|
|
doc.innerText = codeSweeper();
|
|
|
|
doc.innerHTML = ccParser(doc.innerHTML);
|
2002-10-12 03:54:56 +00:00
|
|
|
alert("Remember to uncheck this Source box again before saving your changes!!");
|
2002-10-10 07:21:32 +00:00
|
|
|
} else {
|
2002-10-12 03:54:56 +00:00
|
|
|
ctlStyle.disabled = ctlFont.disabled = ctlSize.disabled = false;
|
2002-10-10 07:21:32 +00:00
|
|
|
doc.style.fontFamily = doc.style.fontSize = "";
|
|
|
|
RichEditor.txtView = true;
|
|
|
|
doc.focus();
|
|
|
|
doc.innerHTML = doc.innerText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// resetMode();
|
|
|
|
function resetMode(){
|
|
|
|
if (switchMode.checked == true) {
|
|
|
|
switchMode.click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ccParser(): colorcode-parser for html-editing view
|
|
|
|
function ccParser(html) {
|
|
|
|
|
|
|
|
html = html.replace(/@/gi,"_AT_");
|
|
|
|
html = html.replace(/#/gi,"_HASH_");
|
|
|
|
|
|
|
|
var htmltag = /(<[\w\/]+[ ]*[\w\=\"\'\.\/\;\: \)\(-]*>)/gi;
|
|
|
|
html = html.replace(htmltag,"<span class=ccp_tag>$1</span>");
|
|
|
|
|
|
|
|
var imgtag = /<span class=ccp_tag>(<IMG[ ]*[\w\=\"\'\.\/\;\: \)\(-]*>)<\/span>/gi;
|
|
|
|
html = html.replace(imgtag,"<span class=ccp_img>$1</span>");
|
|
|
|
|
|
|
|
var formtag = /<span class=ccp_tag>(<[\/]*(form|input){1}[ ]*[\w\=\"\'\.\/\;\: \)\(-]*>)<\/span>/gi;
|
|
|
|
html = html.replace(formtag,"<br><span class=ccp_form>$1</span>");
|
|
|
|
|
|
|
|
var tabletag = /<span class=ccp_tag>(<[\/]*(table|tbody|th|tr|td){1}([ ]*[\w\=\"\'\.\/\;\:\)\(-]*){0,}>)<\/span>/gi;
|
|
|
|
html = html.replace(tabletag,"<span class=ccp_table>$1</span>");
|
|
|
|
|
|
|
|
//var Atag = /<span class=ccp_tag>(<(\/a>|[\W _\w\=\"\'\.\/\;\:\)\(-]>){1})<\/span>/gi;
|
|
|
|
var Atag = /<span class=ccp_tag>(<\/a>){1}<\/span>/gi;
|
|
|
|
html = html.replace(Atag,"<span class=ccp_A>$1</span>");
|
|
|
|
|
|
|
|
var Atag = /<span class=ccp_tag>(<a [\W _\w\=\"\'\.\/\;\:\)\(-]+>){1,}<\/span>/gi;
|
|
|
|
html = html.replace(Atag,"<span class=ccp_A>$1</span>");
|
|
|
|
|
|
|
|
var parameter = /=("[ \w\'\.\/\;\:\)\(-]+"|'[ \w\"\.\/\;\:\)\(-]+')/gi;
|
|
|
|
html = html.replace(parameter,"=<span class=ccp_paramvalue>$1</span>");
|
|
|
|
|
|
|
|
var entity = /&([\w]+);/gi;
|
|
|
|
html = html.replace(entity,"<span class=ccp_entity>&$1;</span>");
|
|
|
|
|
|
|
|
var comment = /(<\!--[\W _\w\=\"\'\.\/\;\:\)\(-]*-->)/gi;
|
|
|
|
html = html.replace(comment,"<br><span class=ccp_htmlcomment>$1</span>");
|
|
|
|
|
|
|
|
html = html.replace(/_AT_/gi,"@");
|
|
|
|
html = html.replace(/_HASH_/gi,"#");
|
|
|
|
|
|
|
|
return html;
|
|
|
|
}
|