Update 0.0.4

Update 0.0.4
This commit is contained in:
dmzx
2015-03-16 16:23:11 +01:00
parent bc1124abee
commit 4afbdcf7fe
37 changed files with 941 additions and 1305 deletions

View File

@@ -28,8 +28,8 @@ function helpline(help)
/**
* Fix a bug involving the TextRange object. From
* http://www.frostjedi.com/terra/scripts/demo/caretBug.html
*/
function initInsertions()
*/
function initInsertions()
{
var doc;
@@ -37,7 +37,7 @@ function initInsertions()
{
doc = document;
}
else
else
{
doc = opener.document;
}
@@ -65,19 +65,18 @@ function initInsertions()
* bbstyle
*/
function bbstyle(bbnumber)
{
{
if (bbnumber != -1)
{
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]);
}
else
}
else
{
insert_text('[*]');
document.forms[form_name].elements[text_name].focus();
}
}
/**
* Apply bbcodes
*/
@@ -110,10 +109,10 @@ function bbfontstyle(bbopen, bbclose)
theSelection = '';
return;
}
//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition(textarea).start;
var new_pos = caret_pos + bbopen.length;
var new_pos = caret_pos + bbopen.length;
// Open tag
insert_text(bbopen + bbclose);
@@ -124,12 +123,12 @@ function bbfontstyle(bbopen, bbclose)
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
}
// IE
else if (document.selection)
{
var range = textarea.createTextRange();
range.move("character", new_pos);
var range = textarea.createTextRange();
range.move("character", new_pos);
range.select();
storeCaret(textarea);
}
@@ -144,16 +143,16 @@ function bbfontstyle(bbopen, bbclose)
function insert_text(text, spaces, popup)
{
var textarea;
if (!popup)
if (!popup)
{
textarea = document.forms[form_name].elements[text_name];
}
else
}
else
{
textarea = opener.document.forms[form_name].elements[text_name];
}
if (spaces)
if (spaces)
{
text = ' ' + text + ' ';
}
@@ -171,7 +170,7 @@ function insert_text(text, spaces, popup)
}
else if (textarea.createTextRange && textarea.caretPos)
{
if (baseHeight != textarea.caretPos.boundingHeight)
if (baseHeight != textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret(textarea);
@@ -184,7 +183,7 @@ function insert_text(text, spaces, popup)
{
textarea.value = textarea.value + text;
}
if (!popup)
if (!popup)
{
textarea.focus();
}
@@ -301,7 +300,7 @@ function split_lines(text)
do
{
var splitAt = line.indexOf(' ', 80);
if (splitAt == -1)
{
splitLines[j] = line;
@@ -329,7 +328,7 @@ function mozWrap(txtarea, open, close)
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;
if (selEnd == 1 || selEnd == 2)
if (selEnd == 1 || selEnd == 2)
{
selEnd = selLength;
}
@@ -389,7 +388,7 @@ function colorPalette(dir, width, height)
{
document.writeln('<tr>');
}
for (b = 0; b < 5; b++)
{
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
@@ -412,7 +411,6 @@ function colorPalette(dir, width, height)
document.writeln('</table>');
}
/**
* Caret Position object
*/
@@ -422,14 +420,13 @@ function caretPosition()
var end = null;
}
/**
* Get the caret position in an textarea
*/
function getCaretPosition(txtarea)
{
var caretPos = new caretPosition();
// simple Gecko/Opera way
if(txtarea.selectionStart || txtarea.selectionStart == 0)
{
@@ -439,26 +436,26 @@ function getCaretPosition(txtarea)
// dirty and slow IE way
else if(document.selection)
{
// get current selection
var range = document.selection.createRange();
// a new selection of the whole textarea
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea);
// calculate selection start point by moving beginning of range_all to beginning of range
var sel_start;
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++)
{
{
range_all.moveStart('character', 1);
}
txtarea.sel_start = sel_start;
// we ignore the end value for IE, this is already dirty enough and we don't need it
caretPos.start = txtarea.sel_start;
caretPos.end = txtarea.sel_start;
caretPos.end = txtarea.sel_start;
}
return caretPos;