var resetValues = {}; function resetValue(editor,option) { var text = resetValues[editor.id]; if (option=="Reset") { text = "\n" + text; editor.setContent(text); } else if (option=="Convert") { text = "\n" + text.replace(/\n/g, "
"); editor.setContent(text); } else if (option=="Revert") { CKEDITOR.instances[editor].destroy() var obj = document.getElementById(editor.id); obj.value = text; } } var sURLPREFIX = "/"; var sREVISIONPREFIX = ""; var sREVISIONPREFIXNOHOST = sREVISIONPREFIX.replace(sURLPREFIX,""); //var revPrefixStr = "<SUB"+" REVISIONPREFIX>"; // separate so it is not replaced by HttpHandler.subst function fitSaveCallback(id, html, body) { // make sure the user did not delete the FIT_CK comment if (html.indexOf("")<0) { html = "" + html; } // get rid of REVISIONPREFIX (ie: smileys) as the revision number will change in future // tried using revPrefixStr, but it was putting <REVISIONPREFIX> when changing from RTF to console html = html.replace(sREVISIONPREFIX,""); html = html.replace(sREVISIONPREFIXNOHOST,""); return html; } var ckEnabled = {}; function ckEnabledRemove(arr,id) { var newArray = {}; for (var key in arr) { if (!arr[i]==key) { newArray[key] = arr[key]; } } return newArray; } function toggleEditor(id) { if (typeof CKEDITOR !== 'undefined') { var obj = document.getElementById(id); if (!CKEDITOR.instances[id]) { resetValues[id] = obj.value; if (obj.value.indexOf("")<0) { // make sure field starts with tag if (obj.value.indexOf('\n') > -1) { var q2 = confirm("You have existing text which does not appear to be from the RTF editor ("+id+"). All newlines will be removed by this editor.\n\nIf you do not like the result, use the custom FIT options (first icon) to convert your original text!\n\nContinue ?"); if (q2==false) { return false; } } obj.value = "" + obj.value; //setCaretTo(obj,16); //does not seem to work on Firefox } //https://ckeditor.com/cke4/builder CKEDITOR.replace(obj, { //customConfig: '../../ckeditor_custom.js', // Add the required plugin extraPlugins : 'pastebase64', } ); //var editor = CKEDITOR.instances[id]; //editor.on( 'paste', function( evt ) { // var rtf = evt.data.dataTransfer.getData( 'application/rtf' ); // if ( rtf ) { // evt.data.dataValue = rtfToHtml( rtf ); // } //} ); } else { CKEDITOR.instances[id].destroy() ckEnabled = ckEnabledRemove(ckEnabled,id); if (!checkValidRtfContent(obj.value)) { obj.value=""; // otherwise, nothing there - don't want to see FIT_TINY tag in regular console } } } } // initialize any that need it function initTiny() { //var count; for(i=0; i<document.entry_form.elements.length; i++) { var element = document.entry_form.elements[i]; if (element.tagName=='TEXTAREA') { var def = element.id; var index = def.indexOf("field"); if (index>0) { // testspec stuff prefixes with tc1, tr2, .. def = def.substr(index); } if (rtfDefaultFields.indexOf(def)>=0) { // defaults to rtf through settings //setTimeout("toggleEditor('"+element.id+"');",10*count++); var obj = document.getElementById(element.id); if (obj.value.length == 0 || obj.value.indexOf("") || obj.value.indexOf("") >= 0) { //only enable editor if field is blank or contains rich text toggleEditor(element.id); } } else if (element.id.length>0) { var obj = document.getElementById(element.id); if (obj && (obj.value.indexOf("")>=0 || obj.value.indexOf("")>=0) ) { // defaults to rtf cause data was edited there before toggleEditor(element.id); } } } } } function rtfCheckLinks() { } function OLDrtfCheckLinks() { var warning = ""; for(i=0; i<document.entry_form.elements.length; i++) { var element = document.entry_form.elements[i]; if (element.tagName=='TEXTAREA') { //var obj = document.getElementById(element.id); //if (obj && obj.value.indexOf("<!-- FIT_TINY -->")>=0) { //alert("i: "+element.id + " : "+element.value); //} var inst = tinyMCE.get(element.id); if (inst) { var imgNodes = inst.getDoc().getElementsByTagName("img"); var n=0; for (n==0; n<imgNodes.length; n++) { var src = imgNodes[n].src; if (src.indexOf("http")<0 && src.indexOf("www")<0) { // appears to be invalid, check if it was already there if (typeof resetValues[element.id]!='undefined') { if (resetValues[element.id].indexOf(src)<0) { warning+=">"+src + "\n"; } } } } } } } if (warning.length>0) { warning=""+ warning + "\n\n"; if (!confirm(warning)) { return false; } } return true; }