Line 7 | Line 7 |
---|
var imageTag = false; var theSelection = false;
|
var imageTag = false; var theSelection = false;
|
| var bbcodeEnabled = true;
|
// Check for Browser & Platform for PC & IE specific bits // More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html var clientPC = navigator.userAgent.toLowerCase(); // Get client info
| // Check for Browser & Platform for PC & IE specific bits // More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html var clientPC = navigator.userAgent.toLowerCase(); // Get client info
|
Line 14 | Line 15 |
---|
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1)); var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
|
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1)); var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
|
| |
var baseHeight;
|
var baseHeight;
|
onload_functions.push('initInsertions()');
| |
/** * Shows the help messages in the helpline window
| /** * Shows the help messages in the helpline window
|
Line 153 | Line 152 |
---|
text = ' ' + text + ' '; }
|
text = ' ' + text + ' '; }
|
if (!isNaN(textarea.selectionStart))
| // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. // Therefore we simply add a !is_ie here until IE fixes the text-selection completely. if (!isNaN(textarea.selectionStart) && !is_ie)
|
{ var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd;
|
{ var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd;
|
mozWrap(textarea, text, '')
| mozWrap(textarea, text, '');
|
textarea.selectionStart = sel_start + text.length; textarea.selectionEnd = sel_end + text.length; }
| textarea.selectionStart = sel_start + text.length; textarea.selectionEnd = sel_end + text.length; }
|
Line 195 | Line 196 |
---|
/** * Add quote text to message */
|
/** * Add quote text to message */
|
function addquote(post_id, username)
| function addquote(post_id, username, l_wrote)
|
{ var message_name = 'message_' + post_id; var theSelection = ''; var divarea = false;
|
{ var message_name = 'message_' + post_id; var theSelection = ''; var divarea = false;
|
| if (l_wrote === undefined) { // Backwards compatibility l_wrote = 'wrote'; }
|
if (document.all) {
| if (document.all) {
|
Line 211 | Line 218 |
---|
}
// Get text selection - not only the post content :(
|
}
// Get text selection - not only the post content :(
|
if (window.getSelection)
| // IE9 must use the document.selection method but has the *.getSelection so we just force no IE if (window.getSelection && !is_ie && !window.opera)
|
{ theSelection = window.getSelection().toString(); }
|
{ theSelection = window.getSelection().toString(); }
|
else if (document.getSelection)
| else if (document.getSelection && !is_ie)
|
{ theSelection = document.getSelection(); }
| { theSelection = document.getSelection(); }
|
Line 250 | Line 258 |
---|
}
if (theSelection)
|
}
if (theSelection)
|
| { if (bbcodeEnabled)
|
{ insert_text('[quote="' + username + '"]' + theSelection + '[/quote]');
|
{ insert_text('[quote="' + username + '"]' + theSelection + '[/quote]');
|
| } else { insert_text(username + ' ' + l_wrote + ':' + '\n'); var lines = split_lines(theSelection); for (i = 0; i < lines.length; i++) { insert_text('> ' + lines[i] + '\n'); } }
|
}
return; }
|
}
return; }
|
| function split_lines(text) { var lines = text.split('\n'); var splitLines = new Array(); var j = 0; for(i = 0; i < lines.length; i++) { if (lines[i].length <= 80) { splitLines[j] = lines[i]; j++; } else { var line = lines[i]; do { var splitAt = line.indexOf(' ', 80); if (splitAt == -1) { splitLines[j] = line; j++; } else { splitLines[j] = line.substring(0, splitAt); line = line.substring(splitAt); j++; } } while(splitAt != -1); } } return splitLines; }
|
/** * From http://www.massless.org/mozedit/ */ function mozWrap(txtarea, open, close) {
|
/** * From http://www.massless.org/mozedit/ */ function mozWrap(txtarea, open, close) {
|
var selLength = txtarea.textLength;
| var selLength = (typeof(txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength;
|
var selStart = txtarea.selectionStart; var selEnd = txtarea.selectionEnd; var scrollTop = txtarea.scrollTop;
| var selStart = txtarea.selectionStart; var selEnd = txtarea.selectionEnd; var scrollTop = txtarea.scrollTop;
|
Line 273 | Line 329 |
---|
}
var s1 = (txtarea.value).substring(0,selStart);
|
}
var s1 = (txtarea.value).substring(0,selStart);
|
var s2 = (txtarea.value).substring(selStart, selEnd)
| var s2 = (txtarea.value).substring(selStart, selEnd);
|
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
|
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
|
txtarea.selectionStart = selEnd + open.length + close.length; txtarea.selectionEnd = txtarea.selectionStart;
| txtarea.selectionStart = selStart + open.length; txtarea.selectionEnd = selEnd + open.length;
|
txtarea.focus(); txtarea.scrollTop = scrollTop;
| txtarea.focus(); txtarea.scrollTop = scrollTop;
|
Line 291 | Line 347 |
---|
*/ function storeCaret(textEl) {
|
*/ function storeCaret(textEl) {
|
if (textEl.createTextRange)
| if (textEl.createTextRange && document.selection)
|
{ textEl.caretPos = document.selection.createRange().duplicate(); }
| { textEl.caretPos = document.selection.createRange().duplicate(); }
|
Line 401 | Line 457 |
---|
return caretPos; }
|
return caretPos; }
|
|
|