", ""];
- var options = [t("Choose style")+":", t("Paragraph"), t(h)+" 1 ", t(h)+" 2 ", t(h)+" 3 ", t(h)+" 4 ", t(h)+" 5 ", t(h)+" 6", t("Address"), t("Fixed width")];
- } else if (select == 'fontname') {
-var values = ["Arial, Helvetica, sans-serif", "Arial, Helvetica, sans-serif","'Arial Black', Helvetica, sans-serif", "'Comic Sans MS' fantasy", "Courier New, Courier, monospace", "Georgia, serif", "Impact,sans-serif","'Times New Roman', Times, serif", "'Trebuchet MS',sans-serif", "Verdana, Arial, Helvetica, sans-serif"];
- var options = [t("Font")+":", "Arial","Arial Black", "Comic", "Courier", "Georgia", "Impact","Times New Roman", "Trebuchet","Verdana"];
- } else if (select == 'fontsize') {
- var values = ["3", "1", "2", "3", "4", "5", "6", "7"];
- var options = [t("Font size")+":", "1 "+t("Small"), "2", "3", "4", "5", "6", "7 "+t("Big")];
- } else {
- var values = vals[select];
- var options = opts[select];
- }
- w(''+"\n");
- for (var i = 0; i < values.length; i++) {
- w(' ' + options[i] + " \n");
- }
- w(" \n");
-}
-function tagButs() {
- w(' ")\' value="H1" title=""> ")\' value="H2" title=""> ")\' value="H3" title=""> ")\' value="H4" title=""> ")\' value="P" title=" "> ")\' value="S" title="" style="font-weight:bold"> ")\' value="E" title="" style="font-style:italic;"> ")\' value="•—" title=""> ")\' value="@" title=""> ")\' value="[♥]" title=" "> ")\' value="←" title=" ">');
-}
-function makeSo(command, option) { //format selected text or line in the whizzy
- hideDialogs();
- if (buts.indexOf(command)!=-1) {insHTML(dobut[command]); return;} //user button
- if (!document.all) oW.document.execCommand('useCSS',false, true); //no spans for bold, italic
- if ("leftrightcenterjustify".indexOf(command) !=-1) command = "justify" + command;
- else if (command == "number") command = "insertorderedlist";
- else if (command == "bullet") command = "insertunorderedlist";
- else if (command == "rule") command = "inserthorizontalrule";
- switch (command) {
- case "color": o('cf_cmd'+idTa).value="forecolor"; if (textSel()) s('COLOR_FORM'+idTa); break;
- case "hilite" : o('cf_cmd'+idTa).value="backcolor"; if (textSel()) s('COLOR_FORM'+idTa); break;
- case "image" : doImage(); break;
- case "link" : doLink(); break;
- case "html" : showHTML(); break;
- case "table" : doTable(); break;
- case "delete_row" : doRow('delete','0'); break;
- case "add_row_above" : doRow('add','0'); break;
- case "add_row_below" : doRow('add','1'); break;
- case "delete_column" : doCol('delete','0'); break;
- case "add_column_before" : doCol('add','0'); break;
- case "add_column_after" : doCol('add','1'); break;
- case "table_in_cell" : hideDialogs(); s('TABLE_FORM'+idTa); break;
- case "clean" : cleanUp(); break;
- case "word" : oW.document.execCommand("paste", false, false); gentleClean=false; cleanUp(); break;
- case "spellcheck" : spellCheck(); break;
- default: oW.document.execCommand(command, false, option);
- }
-}
-function doSelect(selectname) { //select on toolbar used - do it
- var idx = o(selectname).selectedIndex;
- var selected = o(selectname).options[idx].value;
- o(selectname).selectedIndex = 0;
- selectname=selectname.replace(idTa,"");
- if (" _formatblock_fontname_fontsize".indexOf('_'+selectname) > 0) {
- var cmd = selectname;
- oW.document.execCommand(cmd, false, selected);
- } else {
- insHTML(selected);
- }
- oW.focus();
-}
-function vC(colour) { // view Color
- if (!colour) colour = o('cf_color'+idTa).value;
- o('cPrvw'+idTa).style.backgroundColor = colour;
- o('cf_color'+idTa).value = colour;
-}
-function sC(color) { //set Color
- hideDialogs();
- var cmd = o('cf_cmd'+idTa).value;
- if (!color) color = o('cf_color'+idTa).value;
- if (rng) rng.select();
- oW.document.execCommand(cmd, false, color);
- oW.focus();
-}
-function doLink(){
- if (textSel()) {
- if (papa.nodeName == 'A') o("lf_url"+idTa).value = papa.href;
- s('LINK_FORM'+idTa);
- }
-}
-function insertLink() {
- if (rng) rng.select();
- URL = o("lf_url"+idTa).value;
- if (URL.replace(/ /g,"") == "") oW.document.execCommand('Unlink',false,null);
- else if (o("lf_new"+idTa).checked) insHTML(' ');
- else oW.document.execCommand('CreateLink',false,URL);
- hideDialogs();
-}
-function doImage(){
- if (papa && papa.nodeName == 'IMG'){
- o("if_url"+idTa).value = papa.src;
- o("if_alt"+idTa).value=papa.alt;
- o("if_side"+idTa).selectedIndex=(papa.align=="left")?1:(papa.align=="right")?2:0;
- o("if_border"+idTa).value=papa.style.border?papa.style.border:papa.border>0?papa.border:0;
- o("if_margin"+idTa).value=papa.style.margin?papa.style.margin:papa.hspace>0?papa.hspace:0;
- }
- s('IMAGE_FORM'+idTa);
-}
-function insertImage(URL, side, border, margin, alt) { // insert image as specified
- hideDialogs();
- if (!URL) URL=o("if_url"+idTa).value;
- if (URL) {
- if (!alt) alt=o("if_alt"+idTa).value ? o("if_alt"+idTa).value: URL.replace(/.*\/(.+)\..*/,"$1");
- img=' ';
- insHTML(img);
- }
-}
-function doTable(){ //show table controls if in a table, else make table
- if (trail && trail.indexOf('TABLE') > 0) s('TABLE_CONTROLS'+idTa);
- else s('TABLE_FORM'+idTa);
-}
-function doRow(toDo,below) { //insert or delete a table row
- var paNode=papa;
- while (paNode.tagName != "TR") paNode=paNode.parentNode;
- var tRow=paNode.rowIndex;
- var tCols=paNode.cells.length;
- while (paNode.tagName != "TABLE") paNode=paNode.parentNode;
- if (toDo == "delete") paNode.deleteRow(tRow);
- else {
- var newRow=paNode.insertRow(tRow+parseInt(below)); //1=below 0=above
- for (i=0; i < tCols; i++){
- var newCell=newRow.insertCell(i);
- newCell.innerHTML="#";
- }
- }
-}
-function doCol(toDo,after) { //insert or delete a column
- var paNode=papa;
- while (paNode.tagName != 'TD') paNode=paNode.parentNode;
- var tCol=paNode.cellIndex;
- while (paNode.tagName != "TABLE") paNode=paNode.parentNode;
- var tRows=paNode.rows.length;
- for (i=0; i < tRows; i++){
- if (toDo == "delete") paNode.rows[i].deleteCell(tCol);
- else {
- var newCell=paNode.rows[i].insertCell(tCol+parseInt(after)); //if after=0 then before
- newCell.innerHTML="#";
- }
- }
-}
-function makeTable() { //insert a table
- hideDialogs();
- var rows=o('tf_rows'+idTa).value;
- var cols=o('tf_cols'+idTa).value;
- var border=o('tf_border'+idTa).value;
- var head=o('tf_head'+idTa).value;
- if ((rows > 0) && (cols > 0)) {
- var table=' ';
- for (var i=1; i <= rows; i++) {
- table=table + "";
- for (var j=1; j <= cols; j++) {
- if (i==1) {
- if (head=="1") table += "Title"+j+" "; //Title1 Title2 etc.
- else table += ""+j+" ";
- }
- else if (j==1) table += ""+i+" ";
- else table += "# ";
- }
- table += " ";
- }
- table += "
";
- insHTML(table);
- }
-}
-function doWin(URL) { //popup for browse function
- ppw=window.open(URL,'popWhizz','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=100');
- ppw.focus();
-}
-function spellCheck() { //check spelling with ieSpell if available
- try {
- var axo=new ActiveXObject("ieSpell.ieSpellExtension");
- axo.CheckAllLinkedDocuments(document);
- } catch(e) {
- if(e.number==-2146827859) {
- if (confirm("ieSpell is not installed on your computer. \n Click [OK] to go to download page."))
- window.open("http://www.iespell.com/download.php","DownLoad");
- } else {
- alert("Error Loading ieSpell: Exception " + e.number);
- }
- }
-}
-function cleanUp(){ //clean up crud inserted by Micro$oft Orifice
- oW.document.execCommand("removeformat",false,null);
- var h=oW.document.body.innerHTML;
- var vicious=false;
- if (gentleClean=="ask") vicious=confirm(t('Remove all styles and classes?'));
- if (!gentleClean || vicious){
- h=h.replace(/<\/?(SPAN|DEL|INS|U|DIR)[^>]*>/gi, "")
- .replace(/\b(CLASS|STYLE)=\"[^\"]*\"/gi, "")
- .replace(/\b(CLASS|STYLE)=\w+/gi, "");
- }
- if(!o('fontname'+idTa) || !o('fontsize'+idTa)) h=h.replace(/<\?FONT[^>]*>/gi, "");
- h=h.replace(/<\/?(FONT|SPAN|COL|XML|ST1|SHAPE|V:|O:|F:|F |PATH|LOCK|IMAGEDATA|STROKE|FORMULAS)[^>]*>/gi, "")
- .replace(/\bCLASS=\"?MSO\w*\"?/gi, "")
- .replace(/[–]/g,'-') //long –
- .replace(/[‘’]/g, "'") //single smartquotes ‘’
- .replace(/[“”]/g, '"') //double smartquotes “”
- .replace(/align="?justify"?/gi, "") //justify sends some browsers mad
- .replace(/<(TABLE|TD|TH|COL)(.*)(WIDTH|HEIGHT)=["'0-9A-Z]*/gi, "<$1$2") //no fixed size tables (%OK) [^A-Za-z>]
- .replace(/<([^>]+)>\s*<\/\1>/gi, ""); //empty tag
- oW.document.body.innerHTML=h;
-}
-function hideDialogs() {
- h('LINK_FORM'+idTa);
- h('IMAGE_FORM'+idTa);
- h('COLOR_FORM'+idTa);
- h('TABLE_FORM'+idTa);
- h('TABLE_CONTROLS'+idTa);
-}
-function showDesign() {
- oW.document.body.innerHTML=tidyD(o(idTa).value);
- h(idTa);
- h('showWYSIWYG'+idTa);
- s('CONTROLS'+idTa);
- s('whizzy'+idTa);
- if(o("whizzy"+idTa).contentDocument) o("whizzy"+idTa).contentDocument.designMode="on"; //FF loses it on hide
- oW.focus();
-}
-function showHTML() {
- var t=(window.get_xhtml) ? get_xhtml(oW.document.body) : oW.document.body.innerHTML;
- o(idTa).value=tidyH(t);
- h('CONTROLS'+idTa);
- h('whizzy'+idTa);
- s(idTa);
- s('showWYSIWYG'+idTa);
- o(idTa).focus();
-}
-
-function syncTextarea() { //tidy up before we go-go
- for (var i=0;i,...
- h=h.replace(/<(\/?)strong([^>]*)>/gi, "<$1B$2>");
- h=h.replace(/<(\/?)em([^>]*)>/gi, "<$1I$2>");
- return h;
-}
-function tidyH(h){ //...but , deprecated
- h=h.replace(/<(\w+)[^>]*>\s*<\/\1>/gi, ""); //empty tag <([^>]+)>\s*<\/\1>
- h=h.replace(/(<\/?)[Bb]>/g, "$1strong>");
- h=h.replace(/(<\/?)[Ii]>/g, "$1em>");
- h=h.replace(/(<\/?)[Bb](\s+[^>]*)>/g, "$1strong$2>");
- h=h.replace(/(<\/?)[Ii](\s+[^>]*)>/g, "$1em$2>");
- h=h.replace(location.href+'#','#'); //IE anchor bug
- return h;
-}
-function kb_handler(e) { // keyboard controls for Moz
- if (e && (e.ctrlKey && e.keyCode == e.DOM_VK_V)||(e.shiftKey && e.keyCode == e.DOM_VK_INSERT))
- {setTimeout('cleanUp()',10);}
- if (e && e.keyCode==13 && papa.nodeName=="BODY") makeSo("formatblock"," ");
- if (e && e.ctrlKey) {
- var k=String.fromCharCode(e.charCode).toLowerCase();
- var cmd=(k=='b')?'bold':(k=='i')?'italic':(k=='u')?'underline':(k=='l')?'link':(k=='m')?'image':'';
- if (cmd) {
- makeSo(cmd, true);
- e.preventDefault(); // stop the event bubble
- e.stopPropagation();
- }
- }
-}
-function doTag(html) { // insert HTML into text area
- var url;
- if (!html) html=prompt("Enter some HTML or text to insert:", "");
- o(idTa).focus();
- if (html == '') {
- url=prompt("Link address:","http://");
- html=' ';
- }
- if (html == ' ') {
- url=prompt("Address of image:","http://");
- var alt=prompt("Description of image");
- html =' ';
- }
- var close='';
- if (html.indexOf('<') == 0 && html.indexOf('br') != 1 && html.indexOf('img') != 1)
- close=html.replace(/<([a-z0-6]+).*/,"<\/$1>");
- if (html != '' && html != '') close += '\n';
- if (document.selection) {
- sel=document.selection.createRange();
- sel.text=html+sel.text+close;
- } else {
- before=o(idTa).value.slice(0,o(idTa).selectionStart);
- sel=o(idTa).value.slice(o(idTa).selectionStart,o(idTa).selectionEnd);
- after=o(idTa).value.slice(o(idTa).selectionEnd);
- o(idTa).value =before+html+sel+close+after;
- }
- o(idTa).focus();
-}
-function insHTML(html) { //insert HTML at current selection
- if (!html) html=prompt("Enter some HTML or text to insert:", "");
- if (html.indexOf('js:') == 0) {
- try{eval(html.replace(/^js:/,''))} catch(e){};
- return;
- }
- try {
- if(sel.type && sel.type!="Text") sel="";
- oW.document.execCommand("inserthtml", false, html + sel);
- }
- catch (e) {
- if (document.selection) {
- if(papa && papa.nodeName == 'IMG') {papa.outerHTML=html;}
- else if(rng) {rng.select(); rng.pasteHTML(html+rng.htmlText);}
- }
- }
- whereAmI();
-}
-function whereAmI(e){//070322
- if (!e) var e=window.event;
- if (window.getSelection){
- sel=oW.getSelection();
- papa=(e && e.type=='mouseup') ? e.target : (sel.anchorNode.nodeName == '#text') ? sel.anchorNode.parentNode : sel.anchorNode;
- } else {
- sel=oW.document.selection;
- rng=sel.createRange();
- papa=(e && e.type=='mouseup')? e.srcElement : (sel.type == "Control") ? rng.item(0) : rng.parentElement();
- }
- var paNode=papa;
- trail=papa.nodeName;
- while (!paNode.nodeName.match(/^(HTML|BODY)/) && paNode.className!="wzCtrl") {
- paNode=paNode.parentNode;
- trail=paNode.nodeName + '>' + trail;
- }
- if (paNode.className=="wzCtrl") trail=sel=rng=null;
- var id=paNode.nodeName=="HTML" ? paNode.getElementsByTagName("BODY")[0].id : paNode.id.replace("CONTROL","");
- c(id);
- window.status=id+":"+trail;
- if (trail.indexOf('TABLE') > 0) s('TABLE_CONTROLS'+idTa); else h('TABLE_CONTROLS'+idTa);
-}
-function c(id) {//set current whizzy
- if (id=="" || whizzies.join().indexOf(id)=='-1') return;
- if (id!=idTa){
- idTa=id;
- try {oW=o("whizzy"+id).contentWindow;} catch(e){alert('set current: '+id);}
- if (oW) {oW.focus();window.status=oW.document.body.id; }
- }
-}
-function textSel() { if (sel && sel.type != "None") return true; else {alert(t("Select some text first")); return false;}}
-function s(id) {o(id).style.display='block';} //show element
-function h(id) {o(id).style.display='none';} //hide element
-function o(id) { return document.getElementById(id); } //get element by ID
-function w(str) { return document.write(str); } //document write
-function t(key) {return (window.language && language[key]) ? language[key] : key;} //translation
\ No newline at end of file