1
1
Fork 0

Remove special case of "url" from insertFormatting

This commit is contained in:
Hypolite Petovan 2017-05-21 13:41:28 -04:00
parent 88e5e06b45
commit d14da1214c
8 changed files with 18 additions and 84 deletions

View file

@ -37,20 +37,12 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }

View file

@ -15,19 +15,11 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") { selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") { textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
}
} }
$(textarea).trigger('change'); $(textarea).trigger('change');

View file

@ -423,20 +423,12 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }

View file

@ -603,20 +603,12 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }

View file

@ -71,20 +71,12 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }

View file

@ -20,24 +20,14 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]"
+ "http://" + textarea.value.substring(start, end)
+ "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) textarea.value = textarea.value.substring(0, start)
+ "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]"
+ textarea.value.substring(end, textarea.value.length); + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }

View file

@ -33,20 +33,12 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }

View file

@ -50,20 +50,12 @@ function insertFormatting(BBcode, id) {
if (document.selection) { if (document.selection) {
textarea.focus(); textarea.focus();
selected = document.selection.createRange(); selected = document.selection.createRange();
if (BBcode == "url") {
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else {
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
}
} else if (textarea.selectionStart || textarea.selectionStart == "0") { } else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart; var start = textarea.selectionStart;
var end = textarea.selectionEnd; var end = textarea.selectionEnd;
if (BBcode == "url") {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} else {
textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
} }
}
return true; return true;
} }