% @ Language=VBScript %>
<% Option Explicit %>
<%
'****************************************************************************************
'** Copyright Notice
'**
'** Web Wiz Rich Text Editor(TM)
'** http://www.richtexteditor.org
'**
'** Copyright (C)2001-2009 Web Wiz(TM). All Rights Reserved.
'**
'** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'.
'**
'** IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE
'** THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE
'** AND DERIVATIVE WORKS IMMEDIATELY.
'**
'** If you have not received a copy of the license with this work then a copy of the latest
'** license contract can be found at:-
'**
'** http://www.webwiz.co.uk/license
'**
'** For more information about this software and for licensing information please contact
'** 'Web Wiz' at the address and website below:-
'**
'** Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England
'** http://www.webwiz.co.uk
'**
'** Removal or modification of this copyright notice will violate the license contract.
'**
'****************************************************************************************
'*************************** SOFTWARE AND CODE MODIFICATIONS ****************************
'**
'** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE
'** AGREEMENT AND IS STRICTLY PROHIBITED
'**
'** If you wish to modify any part of this software a license must be purchased
'**
'****************************************************************************************
Response.AddHeader "pragma","cache"
Response.AddHeader "cache-control","public"
Response.CacheControl = "Public"
Dim strTextAreaName
strTextAreaName = removeAllTags(Request.QueryString("textArea"))
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
Response.Write(vbCrLf & "")
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>
var colour;
var htmlOn;
var textAreaName = '<% = strTextAreaName %>';
<%
'***********************************************
'*** JavaScript initialising RTE editor *****
'***********************************************
%>
//initialise RTE editor
function initialiseWebWizRTE(){
var textArea = document.getElementById(textAreaName);
var textAreaWidth = parseInt(textArea.offsetWidth);
var textAreaHeight = parseInt(textArea.offsetHeight);
//hide textarea
textArea.style.display = 'none';
//create the iframe
var iframe = document.createElement('iframe');
iframe.frameBorder = 0; //added for IE in XHTML to remove border
iframe.setAttribute('id', 'WebWizRTE');
textArea.parentNode.insertBefore(iframe, textArea);
//style iframe
iframe.style.width = textAreaWidth + 'px';
iframe.style.height = textAreaHeight + 'px';
iframe.style.border = '#A5ACB2 1px solid';
//make toolbar the same size
document.getElementById('toolbar').width = textAreaWidth + 2 + 'px';
var editor = document.getElementById('WebWizRTE').contentWindow.document;
//create iframe page content
var iframeContent;
iframeContent = '\n';
iframeContent += '
\n';
iframeContent += '\n';
iframeContent += '\n';
iframeContent += '\n';
iframeContent += '\n';
iframeContent += textArea.value;
iframeContent += '\n';
iframeContent += '';
editor.open();
editor.write(iframeContent);
editor.close();
function initIframe(){
<%
'IE uses contentEditable instead of designMode to prevent runtime errors in IE6.0.26 to IE6.0.28
'IE uses proprietary attachEvent instead of following the W3C Events module and using addEventListener
'IE SUCKS!!
If RTEenabled = "winIE" Then
%>
editor.attachEvent('onkeypress', editorEvents);
editor.attachEvent('onmousedown', editorEvents);
document.attachEvent('onmousedown', hideIframes);
editor.body.contentEditable = true;
<%
'Gekco and Opera need designMode enabled AFTER we listen for events using addEventListener
Else
%> editor.addEventListener('keypress', editorEvents, true);
editor.addEventListener('mousedown', editorEvents, true);
document.addEventListener('mousedown', hideIframes, true);
editor.designMode = 'on';
<%
End If
%> }
setTimeout(initIframe, 300);
//get present onsubmit events
if (typeof textArea.form.onsubmit == 'function'){
textArea.form.originalOnSubmit = [];
textArea.form.originalOnSubmit.push(textArea.form.onsubmit);
}
//get textrea value from RTE and run any original onSubmit events
textArea.form.onsubmit = function(){
textArea.value = editor.body.innerHTML;
for (i in this.originalOnSubmit){
return this.originalOnSubmit[i]();
}
}
//resetting the form
textArea.form.onreset = function(){
if (window.confirm('<% = strResetWarningFormConfirm %>')){
editor.body.innerHTML = '';
return true;
}
return false;
}
//unload event so we don't loose the data
window.onunload = function(){
textArea.value = editor.body.innerHTML;
}
}
<%
'**********************************************
'*** JavaScript create RTE toolbar *****
'**********************************************
%>
//Create RTE toolbar
function WebWizRTEtoolbar(formName){
<%
'Open Iframes
'Colour Palette iframe
If blnTextColour OR blnTextBackgroundColour Then
Response.Write(vbCrLf & " document.writeln('');")
End If
'Format font Select iframe
If blnFontStyle Then
Response.Write(vbCrLf & " document.writeln('');")
End If
'Font Select iframe
If blnFontType Then
Response.Write(vbCrLf & " document.writeln('');")
End If
'Font Size iframe
If blnFontSize Then
Response.Write(vbCrLf & " document.writeln('');")
End If
%>
document.writeln('
');
document.writeln('
');
document.writeln('
');
document.writeln('
');
document.writeln('
');
document.writeln('
');
}
<%
'***********************************************
'*** JavaScript for main editor buttons *****
'***********************************************
%>
//Function to format text in the text box
function FormatText(command, option){<%
'If this is the Gecko engine then uncomment the following line if you don't wish to use CSS
If RTEenabled = "Gecko" AND blnUseCSS = false Then Response.Write(" document.getElementById('WebWizRTE').contentWindow.document.execCommand(""useCSS"", false, option);")
%>
var editor = document.getElementById('WebWizRTE');
//Show iframes
if ((command == 'forecolor') || (command == 'backcolor') || (command == 'hilitecolor') || (command == 'fontname') || (command == 'formatblock') || (command == 'fontsize')){
parent.command = command;
buttonElement = document.getElementById(command);
switch (command){
case 'fontname': iframeWin = 'fontSelect'; break;
case 'formatblock': iframeWin = 'formatFont'; break;
case 'fontsize': iframeWin = 'textSize'; break;
default: iframeWin = 'colourPalette';
}
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
document.getElementById(iframeWin).style.left = getOffsetLeft(buttonElement) + 'px';
document.getElementById(iframeWin).style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + 'px';
if (document.getElementById(iframeWin).style.visibility=='visible'){
hideIframes();
}else{
hideIframes();
document.getElementById(iframeWin).style.visibility='visible';
}
var selectedRange = editor.contentWindow.document.selection;
if (selectedRange != null){
range = selectedRange.createRange();
}
}<%
'If this is the Gecko or Opera then check the users preferences are set to cut, copy, or paste
If RTEenabled = "Gecko" OR RTEenabled = "opera" Then
%>
//Paste for AppleWebKit (Safari & Chrome)
else if ((navigator.userAgent.indexOf('AppleWebKit') > 0) & (command == 'paste')){
alert('<% = strTxtYourBrowserSettingsDoNotPermit %> \'' + command + '\' <% = strTxtPleaseUseKeybordsShortcut %> \(<% = strTxtWindowsUsers %> Ctrl + v, <% = strTxtMacUsers %> Apple + v\)')
}
//Cut, copy, paste for Gecko
else if ((command == 'cut') || (command == 'copy') || (command == 'paste')){
try{
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
editor.contentWindow.document.execCommand(command, false, option);
}catch(exception){
switch(command){
case 'cut': keyboard = 'x'; break;
case 'copy': keyboard = 'c'; break;
case 'paste': keyboard = 'v'; break;
}
alert('<% = strTxtYourBrowserSettingsDoNotPermit %> \'' + command + '\' <% = strTxtPleaseUseKeybordsShortcut %> \(<% = strTxtWindowsUsers %> Ctrl + ' + keyboard + ', <% = strTxtMacUsers %> Apple + ' + keyboard + '\)')
}
}<%
End If
'If the advanced hyperlink is not enabled then display a basic hyperlink function
If blnAdvAdddHyperlink = false Then
%>
else if (command == 'createLink'){
<%
'Mozilla and Opera use different methods than IE to get the selected text
If RTEenabled = "Gecko" OR RTEenabled = "opera" Then
Response.Write(" var selectedRange = editor.contentWindow.window.getSelection().toString();")
Else
Response.Write(" var selectedRange = editor.contentWindow.document.selection.createRange().text; ")
End If
%>
if (selectedRange != null && selectedRange != ''){
//place http infront if not already in selected range
if (selectedRange.substring(0,4) != 'http'){
selectedRange = 'http://' + selectedRange
}
insertLink = prompt('<% = strTxtEnterHeperlinkURL %>', selectedRange);
if ((insertLink != null) && (insertLink != '')){
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
editor.contentWindow.document.execCommand('CreateLink', false, insertLink);
}
}else{
alert('<% = strTxtSelectTextToTurnIntoHyperlink %>')
}
}<%
End If
'Else none of the other command need extra code so run the command as a bsic execCommand in the editor
%>
else{
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
editor.contentWindow.document.queryCommandEnabled(command)
editor.contentWindow.document.execCommand(command, false, option);
}
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus();")
End If
%>
}
<%
'***********************************************************************************
'************************************************************************
'*** JavaScript for initialise commands (iframe colours etc.) *****
'************************************************************************
%>
//Function to initialise commands
function initialiseCommand(selection){
var editor = document.getElementById('WebWizRTE')
<%
'If this is IE then use the following
If RTEenabled = "winIE" Then
%>
//retrieve selected range
var selectedRange = editor.contentWindow.document.selection;
if (selectedRange!=null){
selectedRange = selectedRange.createRange();
selectedRange = range;
selectedRange.select();
}<%
End If
%>
editor.contentWindow.document.execCommand(parent.command, false, selection);
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
hideIframes();
}
<%
'*****************************************************
'*** JavaScript for switching to HTML view *****
'*****************************************************
If blnHTMLView Then
%>
//Function to switch to HTML view
function HTMLview(){
var editor = document.getElementById('WebWizRTE');
<%
'If this is IE then use the following
If RTEenabled = "winIE" Then
%>
//WYSIWYG view
if (htmlOn == true){
var html = editor.contentWindow.document.body.innerText;
editor.contentWindow.document.body.innerHTML = html;
document.getElementById('ToolBar1').style.visibility='visible';
document.getElementById('ToolBar2').style.visibility='visible';
htmlOn = false;
//HTML view
}else{
var html = editor.contentWindow.document.body.innerHTML;
editor.contentWindow.document.body.innerText = html;
document.getElementById('ToolBar1').style.visibility='hidden';
document.getElementById('ToolBar2').style.visibility='hidden';
htmlOn = true;
}<%
'Else for Midas
Else
%>
//WYSIWYG view
if (htmlOn == true){
var html = editor.contentWindow.document.body.ownerDocument.createRange();
html.selectNodeContents(editor.contentWindow.document.body);
editor.contentWindow.document.body.innerHTML = html.toString();
document.getElementById('ToolBar1').style.visibility='visible';
document.getElementById('ToolBar2').style.visibility='visible';
htmlOn = false;
//HTML view
}else{
var html = document.createTextNode(editor.contentWindow.document.body.innerHTML);
editor.contentWindow.document.body.innerHTML = '';
editor.contentWindow.document.body.appendChild(html);
document.getElementById('ToolBar1').style.visibility='hidden';
document.getElementById('ToolBar2').style.visibility='hidden';
htmlOn = true;
}
<%
End If
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
}
<%
End If
'***********************************************
'*** JavaScript for print content *****
'***********************************************
If blnPrint Then
%>
//Function to print editor content
function printEditor(){
<%
'If this is Gekco or Opera then print method is different to IE
If RTEenabled = "Gecko" OR RTEenabled = "opera" Then
Response.Write(" document.getElementById('WebWizRTE').contentWindow.print();")
Else
Response.Write(" document.getElementById('WebWizRTE').contentWindow.document.execCommand('Print');")
End If
%>
}
<%
End If
'***********************************************
'*** JavaScript for clear button *****
'***********************************************
'If new doc is enabled then include the following function
If blnNew Then
%>
//Function to clear editor content
function clearWebWizRTE(){
if (window.confirm('<% = strResetWarningEditorConfirm %>')){
document.getElementById('WebWizRTE').contentWindow.document.body.innerHTML='';
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" document.getElementById('WebWizRTE').focus();")
Else
Response.Write(" document.getElementById('WebWizRTE').contentWindow.focus()")
End If
%>
}
}
<%
End If
'***********************************************
'*** JavaScript for iframes position *****
'***********************************************
%>
//Iframe top offset
function getOffsetTop(elm){
var mOffsetTop = elm.offsetTop;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetTop += mOffsetParent.offsetTop;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetTop;
}
//Iframe left offset
function getOffsetLeft(elm){
var mOffsetLeft = elm.offsetLeft;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetLeft += mOffsetParent.offsetLeft;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetLeft;
}
<%
'***********************************************
'*** JavaScript for iframe hidding *****
'***********************************************
Response.Write("//Function to hide iframes" & _
vbCrLf & "function hideIframes(){")
If blnTextColour OR blnTextBackgroundColour OR blnFontStyle OR blnFontType OR blnFontSize Then
'Colour Palette iframe
If blnTextColour OR blnTextBackgroundColour Then
Response.Write(vbCrLf & " if (document.getElementById('colourPalette').style.visibility=='visible'){document.getElementById('colourPalette').style.visibility='hidden';}")
End If
'Format font Select iframe
If blnFontStyle Then
Response.Write(vbCrLf & " if (document.getElementById('formatFont').style.visibility=='visible'){document.getElementById('formatFont').style.visibility='hidden';}")
End If
'Font Select iframe
If blnFontType Then
Response.Write(vbCrLf & " if (document.getElementById('fontSelect').style.visibility=='visible'){document.getElementById('fontSelect').style.visibility='hidden';}")
End If
'Font Size iframe
If blnFontSize Then
Response.Write(vbCrLf & " if (document.getElementById('textSize').style.visibility=='visible'){document.getElementById('textSize').style.visibility='hidden';}")
End If
End If
Response.Write(vbCrLf & "}")
'***********************************************
'*** JavaScript for spell check detection *****
'***********************************************
'If spell checking is enabled load the following function
If blnSpellCheck AND RTEenabled = "winIE" Then
%>
//Function to perform spell check
function checkspell(){
try{
var tmpis = new ActiveXObject('ieSpell.ieSpellExtension');
tmpis.CheckAllLinkedDocuments(document);
}
catch(exception){
if(exception.number==-2146827859){
if (confirm('<% = strTxtIeSpellNotDetected %>')){
window.open('http://www.iespell.com/download.php','DownLoad', '');
}
}
else
alert('Error Loading ieSpell: Exception ' + exception.number);
}
}<%
End If
'***********************************************
'*** Editor Keybord/Mouse Events *****
'***********************************************
%>
//Run Editor Events
function editorEvents(evt){
var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
var keyCodeChar = String.fromCharCode(keyCode).toLowerCase();
<%
'Put in some keybord shortcuts Gecko doesn't have when in RTE mode (IE and Opera already have these built in)
If RTEenabled = "Gecko" Then
%>
//Keyboard shortcuts
if (evt.type=='keypress' && evt.ctrlKey){
var kbShortcut;
switch (keyCodeChar){
case 'b': kbShortcut = 'bold'; break;
case 'i': kbShortcut = 'italic'; break;
case 'u': kbShortcut = 'underline'; break;
case 's': kbShortcut = 'strikethrough'; break;
case 'i': kbShortcut = 'italic'; break;
}
if (kbShortcut){
FormatText(kbShortcut, '');
evt.preventDefault();
evt.stopPropagation();
}
}
<%
End If
'Prevent double line spacing in IE (IE SUCKS!!!)
'If this is IE then detect if ENTER key is prssed then replace
with
'I would replace
with , but this then courses problems within tables, ordered lists, and
'other elements so
is used as it creates the same one line effect but without the problems
If RTEenabled = "winIE" AND blnNoIEdblLine Then
%>
//run if enter key is pressed
if (evt.type=='keypress' && keyCode==13){
var editor = document.getElementById('WebWizRTE');
var selectedRange = editor.contentWindow.document.selection.createRange();
var parentElement = selectedRange.parentElement();
var tagName = parentElement.tagName;
while((/^(a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|kbd|label|q|s|samp|select|small|span|strike|strong|sub|sup|textarea|tt|u|var)$/i.test(tagName)) && (tagName!='HTML')){
parentElement = parentElement.parentElement;
tagName = parentElement.tagName;
}
//Insert
instead of
if (parentElement.tagName == 'P'||parentElement.tagName=='BODY'||parentElement.tagName=='HTML'||parentElement.tagName=='TD'||parentElement.tagName=='THEAD'||parentElement.tagName=='TFOOT'){
selectedRange.pasteHTML('
');
selectedRange.select();
return false;
}
}<%
End If
%>
hideIframes();
return true;
}