diff --git a/serendipity_editor.js b/serendipity_editor.js index 9c983d06..fe925ec4 100644 --- a/serendipity_editor.js +++ b/serendipity_editor.js @@ -175,12 +175,13 @@ function serendipity_imageSelector_addToElement (str, el) function serendipity_imageSelector_addToBody (str, textarea) { + var oEditor; // check for CKEDITOR usage if (typeof(CKEDITOR) != 'undefined') { // if here the blog uses CKEDITOR - var oEditor = isinstance; // build-in by ckeditor plugin + oEditor = isinstance; // build-in by ckeditor plugin if (oEditor.mode == "wysiwyg") { // if here the editior is in WYSIWYG mode so use the insert html function @@ -192,7 +193,7 @@ function serendipity_imageSelector_addToBody (str, textarea) } else if (typeof(FCKeditorAPI) != 'undefined') { // if here the blog uses FCK editor - var oEditor = FCKeditorAPI.GetInstance('serendipity[' + textarea + ']') ; + oEditor = FCKeditorAPI.GetInstance('serendipity[' + textarea + ']') ; if (oEditor.EditMode == FCK_EDITMODE_WYSIWYG) { // if here the editior is in WYSIWYG mode so use the insert html function @@ -205,8 +206,6 @@ function serendipity_imageSelector_addToBody (str, textarea) } else if(typeof(xinha_editors) != 'undefined') { // if here the blog uses Xinha editor - var oEditor; - if (typeof(xinha_editors['serendipity[' + textarea + ']']) != 'undefined') { // this is good for the two default editors (body & extended) oEditor = xinha_editors['serendipity['+ textarea +']']; @@ -239,19 +238,19 @@ function serendipity_imageSelector_addToBody (str, textarea) } } else if(typeof(HTMLArea) != 'undefined') { // if here the blog uses HTMLArea editor - var oEditor; + oEditor; if (textarea == 'body' && typeof(editorbody) != 'undefined') { oEditor = editorbody; } else if (textarea == 'extended' && typeof(editorextended) != 'undefined') { oEditor = editorextended; } else if (typeof(htmlarea_editors) != 'undefined' && typeof(htmlarea_editors[textarea]) != 'undefined') { - oEditor = htmlarea_editors[textarea]; + oEditor = htmlarea_editors[textarea]; } // the actual insert for the HTMLArea editor if (oEditor._editMode != 'textmode') { - // if here the editior is in WYSIWYG mode so use the insert html function + // if here the editor is in WYSIWYG mode so use the insert html function oEditor.insertHTML(str); } else { // if here just insert the text to the textarea ( named with the value of textarea variable ) @@ -260,15 +259,14 @@ function serendipity_imageSelector_addToBody (str, textarea) } else if(typeof(TinyMCE) != 'undefined') { // for the TinyMCE editor we do not have a text mode insert - //tinyMCE.execCommand('mceInsertContent', false, str); tinyMCE.execInstanceCommand('serendipity[' + textarea + ']', 'mceInsertContent', false, str); - } else { + } else { noWysiwygAdd(str, textarea); } } - +// this is used by noWysiwygAdd() in nugget textareas function urldecode(url) { return decodeURIComponent(url.replace(/\+/g, ' ')); @@ -287,7 +285,7 @@ function noWysiwygAdd( str, textarea ) } else { //eltarget = document.forms[0].elements[0]; // this did not work in staticpages textareas var elements = document.getElementsByTagName("textarea"); - for (var i = 0; i < elements.length; ++i) { + for (var i = 0; i < elements.length; ++i) { if (elements[i].getAttribute("name") == urldecode(textarea)) { eltarget = elements[i]; }