/* +-------------------------------------------------------------------+ | J S - R I C H E D I T (v1.18) | | | | Copyright Gerd Tentler www.gerd-tentler.de/tools | | Created: Jun. 2, 2003 Last modified: Feb. 10, 2007 | +-------------------------------------------------------------------+ | This program may be used and hosted free of charge by anyone for | | personal purpose as long as this copyright notice remains intact. | | | | Obtain permission before selling the code for this program or | | hosting this software on a commercial website or redistributing | | this software over the Internet or in any other medium. In all | | cases copyright must remain intact. | +-------------------------------------------------------------------+ =========================================================================================================== This script was tested with the following systems and browsers: - Windows XP: IE 6, NN 7, Opera 7 + 9, Firefox 2 - Mac OS X: IE 5, Safari 1 If you use another browser or system, this script may not work for you - sorry. Generally, richtext editing should work on Windows with Internet Explorer 4+ and with browsers using the Mozilla 1.3+ engine, i.e. all browsers that support "designMode". NOTE: The following browsers have been tested and do NOT support richtext editing: NN 7.0 and Opera 7.0 + 9.0 on Windows, IE 5.2 and Safari 1.0 on Mac OS. However, the script works with them, too - a simple textarea will replace the richtext editor. =========================================================================================================== */ var OP = (navigator.userAgent.indexOf('Opera') != -1) ? true : false; var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP) ? true : false; var GK = (navigator.userAgent.indexOf('Gecko') != -1) ? true : false; var DM = (document.designMode && document.execCommand) ? true : false; var rto = new Array(); var mouseX, mouseY, winX, winY, scrLeft, scrTop; //--------------------------------------------------------------------------------------------------------- // Language settings //--------------------------------------------------------------------------------------------------------- var txtParagraph = "Paragraph"; var txtNormal = "Normal"; var txtHeading = "Heading"; var txtClearFormatting = "Clear Formatting"; var txtJustifyLeft = "Justify Left"; var txtJustifyCenter = "Justify Center"; var txtJustifyRight = "Justify Right"; var txtJustifyFull = "Justify Full"; var txtOrderedList = "Ordered List"; var txtUnorderedList = "Unordered List"; var txtOutdent = "Outdent"; var txtIndent = "Indent"; var txtInsertHR = "Insert Horizontal Rule"; var txtInsertTable = "Insert Table"; var txtInsertGraph = "Insert Graph"; var txtInsertBullet = "Insert Bullet Point"; var txtInsertImage = "Insert Image"; var txtInsertText = "Insert text here"; var txtFont = "Font"; var txtSize = "Size"; var txtBold = "Bold"; var txtItalic = "Italic"; var txtUnderline = "Underline"; var txtFontColor = "Font Color"; var txtBGColor = "Background Color"; var txtHyperlink = "Hyperlink"; var txtCut = "Cut"; var txtCopy = "Copy"; var txtPaste = "Paste"; var txtUndo = "Undo"; var txtRedo = "Redo"; var txtBorder = "Border"; var txtBorderColor = "Border Color"; var txtCellColor = "Cell Color"; var txtCellSpacing = "Cell Spacing"; var txtCellPadding = "Cell Padding"; var txtColumns = "Columns"; var txtRows = "Rows"; var txtCreate = "Create"; var txtCancel = "Cancel"; var txtValues = "Values"; var txtLabels = "Labels"; var txtBarColor = "Bar Color"; var txtLabelColor = "Label Color"; var txtViewValues = "View Values"; var txtLegend = "Legend"; var txtViewSource = "View Source"; var txtViewEditor = "View Editor"; function EDITOR() { //--------------------------------------------------------------------------------------------------------- // Configuration //--------------------------------------------------------------------------------------------------------- this.editorBGColor = "white"; // editor background color this.editorBorder = "1px silver"; // editor border (CSS-spec: "size style color") this.textWidth = 500; // text field width (pixels) this.textHeight = 140; // text field height (pixels) this.textBGColor = "white"; // text field background color this.textBorder = "2px inset"; // text field border (CSS-spec: "size style color") this.textFont = "Verdana, Arial, Helvetica"; // text field font family (CSS-spec) this.textFontSize = 11; // text field font size (pixels) this.setFocus = false; // focus text field on load (true or false) this.fieldName = "htmlcontent"; // default field name this.iconPath = "includes/htmlEditor/icons"; // path to icons this.bulletpoint = "bp.gif"; // bullet point image (full path) //--------------------------------------------------------------------------------------------------------- // Functions //--------------------------------------------------------------------------------------------------------- this.editor = 0; this.id = 0; this.curSelection = 0; this.field = ''; this.curFontColor = 'gray'; this.curBGColor = 'yellow'; this.source = false; this.getEditor = function() { var e = false; if(GK) e = document.getElementById('rtoIFrame' + this.id).contentWindow; else if(IE) e = document.frames('rtoIFrame' + this.id); if(e && !DM) e = false; return e; } this.wordWrap = function(string, col, prefix) { if(col == null) col = 100; if(prefix == null) prefix = ''; var text = line = newline = word = ''; var row = col - prefix.length; var i, j, cnt; var words = new Array(); var lines = new Array(); lines = string.split('\n'); if(row > 0) { for(i = 0; i < lines.length; i++) { line = lines[i]; if(line.length > row) { newline = ''; words = line.split(' '); for(j = 0; j < words.length; j++) { word = words[j]; if(word.length > row) { if(newline) { text += prefix + newline + '\n'; newline = ''; } text += prefix + word + '\n'; } else if(newline.length + word.length > row) { newline.replace(/ +$/, ''); text += prefix + newline + '\n'; newline = word + ' '; } else newline += word + ' '; } newline.replace(/ +$/, ''); text += prefix + newline + '\n'; } else { line.replace(/ +$/, ''); text += prefix + line + '\n'; } } } return text.replace(/\n$/, ''); } this.initEditor = function(content) { if(this.editor = this.getEditor()) { var html = '
' + '' + content.replace(/\n' + content; this.field.value = content; } } } this.buildEditor = function() { document.writeln(''); document.writeln('| '+ //**** REMOVED PARAGRAPH OPTIONS *********************** // '; ' | '); document.writeln(''); document.writeln(' | '); document.writeln(' |
| ' + //**** REMOVED FONT OPTIONS *********************** // ' ' | '); document.writeln(''); document.writeln(' | '); document.writeln(' | '); document.writeln(' |
';
var sum = max = max_neg = max_dec = ccnt = lcnt = 0;
for(var i = 0; i < bars; i++) {
if(typeof(d[i]) == 'string') drw = d[i].split(';');
else {
drw = new Array();
drw[0] = d[i];
}
val[lcnt] = new Array();
for(var j = v = 0; j < drw.length; j++) {
val[lcnt][j] = v = drw[j] ? parseFloat(drw[j]) : 0;
if(v > max) max = v;
else if(v < max_neg) max_neg = v;
if(v < 0) v *= -1;
sum += v;
v = v.toString();
if(v.indexOf('.') != -1) {
v = v.substr(v.indexOf('.') + 1);
dec = v.length;
if(dec > max_dec) max_dec = dec;
}
if(!bc[j]) {
if(ccnt >= colors.length) ccnt = 0;
bc[j] = (!drf[j] || drf[j].length < 3) ? colors[ccnt++] : drf[j];
}
}
lcnt++;
}
if(!showVal) showVal = 0;
if(!bBorder) bBorder = '2px outset white';
if(!bSize) bSize = 15;
if(!bLen) bLen = 1.0;
else if(bLen < 0.1) bLen = 0.1;
else if(bLen > 2.9) bLen = 2.9;
var border = parseInt(bBorder);
var mPerc = sum ? Math.round(max * 100 / sum) : 0;
var mul = mPerc ? 100 / mPerc : 1;
mul *= bLen;
if(showVal < 2) var valSpace = 25;
else var valSpace = 0;
var spacer = maxSize = Math.round(mPerc * mul + valSpace + border * 2);
if(max_neg) {
var mPerc_neg = sum ? Math.round(-max_neg * 100 / sum) : 0;
var spacer_neg = Math.round(mPerc_neg * mul + valSpace + border * 2);
maxSize += spacer_neg;
}
graph += '
| ';
var l = (typeof(legend) == 'string') ? this.makeArray(legend) : legend;
for(i = 0; i < bc.length; i++) {
graph += ' '; } graph += ' |
' + txtBGColor + '
' + '' + '' + txtFontColor + '
' + '' + '' + txtInsertImage + '
' + '' + '' + txtInsertTable + '
' + '' + '' + txtInsertGraph + '
' + '' + '