diff --git a/serendipity_editor.js b/serendipity_editor.js
index a93afd14..e3a048c7 100644
--- a/serendipity_editor.js
+++ b/serendipity_editor.js
@@ -15,8 +15,11 @@
if there are any problems, let chris know.
*/
+
+// This variable isn't used anywhere else?
var thisForm;
+// ?
function getMozSelection(txtarea) {
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
@@ -25,13 +28,16 @@ function getMozSelection(txtarea) {
if (selEnd==1 || selEnd==2) {
selEnd=selLength;
}
+
return (txtarea.value).substring(selStart, selEnd);
}
+// ?
function getIESelection(txtarea) {
return document.selection.createRange().text;
}
+// ?
function mozWrap(txtarea, lft, rgt) {
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
@@ -39,17 +45,21 @@ function mozWrap(txtarea, lft, rgt) {
if (txtarea.setSelectionRange) {
if (selEnd==1 || selEnd==2) selEnd=selLength;
+
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
+
txtarea.value = s1 + lft + s2 + rgt + s3;
} else {
txtarea.value = txtarea.value + ' ' + lft + rgt + ' ';
}
}
+// ?
function IEWrap(txtarea, lft, rgt) {
strSelection = document.selection.createRange().text;
+
if (strSelection != "") {
document.selection.createRange().text = lft + strSelection + rgt;
} else {
@@ -57,8 +67,10 @@ function IEWrap(txtarea, lft, rgt) {
}
}
+// ?
function wrapSelection(txtarea, lft, rgt) {
scrollPos = false;
+
if (txtarea.scrollTop) {
scrollPos = txtarea.scrollTop;
}
@@ -75,6 +87,7 @@ function wrapSelection(txtarea, lft, rgt) {
}
}
+// ?
function wrapSelectionWithLink(txtarea) {
var my_link = prompt("Enter URL:","http://");
@@ -86,17 +99,20 @@ function wrapSelectionWithLink(txtarea) {
var my_title = prompt("Enter title/tooltip:", "");
html_title = "";
+
if (my_title != "" && my_title != null) {
html_title = ' title="' + my_title + '"';
}
if (my_link != null) {
lft = "";
+
if (my_desc != null && my_desc != "") {
rgt = my_desc + "";
} else {
rgt = "";
}
+
wrapSelection(txtarea, lft, rgt);
}
@@ -104,31 +120,39 @@ function wrapSelectionWithLink(txtarea) {
}
/* end chris w. script */
+// ?
function mozInsert(txtarea, str) {
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
+
if (selEnd==1 || selEnd==2) {
selEnd=selLength;
}
+
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
+
txtarea.value = s1 + str + s2 + s3;
}
+// ?
function wrapInsImage(area) {
var loc = prompt('Enter the Image Location: ');
+
if (!loc) {
return;
}
+
mozInsert(area,'');
}
-
/* end Better-Editor functions */
+// ?
function serendipity_insImage (area) {
var loc = prompt('Enter the Image Location: ');
+
if (!loc) {
area.focus();
return;
@@ -138,11 +162,13 @@ function serendipity_insImage (area) {
area.focus();
}
+// ?
function serendipity_insBasic (area, tag) {
area.value = area.value + "<" + tag + ">" + tag + ">";
area.focus();
}
+// ?
function serendipity_insLink (area) {
var loc = prompt('Enter URL Location: ');
var text = prompt('Enter Description: ');
@@ -154,6 +180,7 @@ function serendipity_insLink (area) {
}
html_title = "";
+
if (my_title != "" && my_title != null) {
html_title = ' title="' + my_title + '"';
}
@@ -162,23 +189,23 @@ function serendipity_insLink (area) {
area.focus();
}
-function serendipity_imageSelector_addToElement (str, el)
-{
+// ?
+function serendipity_imageSelector_addToElement (str, el) {
document.getElementById(el).value = str;
+
if (document.getElementById(el).type != 'hidden' && document.getElementById(el).focus) {
document.getElementById(el).focus();
}
+
if (document.getElementById(el).onchange) {
document.getElementById(el).onchange();
}
}
-function serendipity_imageSelector_addToBody (str, textarea)
-{
-
+// ?
+function serendipity_imageSelector_addToBody (str, textarea) {
// check for FCKEditor usage
if (typeof(FCKeditorAPI) != 'undefined') {
-
// if here the blog uses FCK editor
var oEditor = FCKeditorAPI.GetInstance('serendipity[' + textarea + ']') ;
@@ -189,9 +216,7 @@ function serendipity_imageSelector_addToBody (str, textarea)
// if here just insert the text to the textarea ( named with the value of textarea variable )
noWysiwygAdd( str, textarea );
}
-
} else if(typeof(xinha_editors) != 'undefined') {
-
// if here the blog uses Xinha editor
var oEditor;
@@ -256,12 +281,13 @@ function serendipity_imageSelector_addToBody (str, textarea)
}
}
-// The noWysiwygAdd JS function is the vanila serendipity_imageSelector_addToBody js function which works fine in NO WYSIWYG mode
+// The noWysiwygAdd JS function is the vanila serendipity_imageSelector_addToBody js function
+// which works fine in NO WYSIWYG mode
// NOTE: the serendipity_imageSelector_addToBody could add any valid HTML string to the textarea
-function noWysiwygAdd( str, textarea )
-{
+function noWysiwygAdd( str, textarea ) {
// default case: no wysiwyg editor
eltarget = '';
+
if (document.forms['serendipityEntry'] && document.forms['serendipityEntry']['serendipity['+ textarea +']']) {
eltarget = document.forms['serendipityEntry']['serendipity['+ textarea +']']
} else if (document.forms['serendipityEntry'] && document.forms['serendipityEntry'][textarea]) {
@@ -271,12 +297,12 @@ function noWysiwygAdd( str, textarea )
}
wrapSelection(eltarget, str, '');
+
eltarget.focus();
}
-
-function serendipity_imageSelector_done(textarea)
-{
+// ?
+function serendipity_imageSelector_done(textarea) {
var insert = '';
var img = '';
var src = '';
@@ -327,6 +353,7 @@ function serendipity_imageSelector_done(textarea)
styled = false; // Templates now do this.
imgID = 0;
+
if (f['imgID']) {
imgID = f['imgID'].value;
}
@@ -336,6 +363,7 @@ function serendipity_imageSelector_done(textarea)
}
floating = 'center';
+
if (f['serendipity[align]'][0].checked == true) {
img = "
";
} else if (f['serendipity[align]'][1].checked == true) {
@@ -355,6 +383,7 @@ function serendipity_imageSelector_done(textarea)
prepend = '';
ilink = f['serendipity[url]'].value;
+
if (!targetval || targetval == 'none') {
itarget = '';
} else if (targetval == 'js') {
@@ -379,6 +408,7 @@ function serendipity_imageSelector_done(textarea)
if (document.getElementById('serendipity_imagecomment').value != '') {
comment = f['serendipity[imagecomment]'].value;
+
block = '