summaryrefslogtreecommitdiff
path: root/js/selection.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/selection.js')
-rw-r--r--js/selection.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/js/selection.js b/js/selection.js
new file mode 100644
index 0000000..fcb738b
--- /dev/null
+++ b/js/selection.js
@@ -0,0 +1,26 @@
+function getSelectionText(divID) {
+ var selectedText = "";
+ if (window.getSelection) {
+ var sel = window.getSelection();
+ var div = document.getElementById(divID);
+
+ if (sel.rangeCount) {
+ // Get the selected range
+ var range = sel.getRangeAt(0);
+ // Check that the selection is wholly contained within the div text
+ // if (range.commonAncestorContainer == div.firstChild) {
+ var selectedText = range.toString();
+ // }
+ }
+ }
+ return selectedText;
+}
+$(document).ready(function() {
+ $("#fix-caption-code").mousedown(function() {
+ $("#edit-caption").val("");
+ });
+ $("#fix-caption-code").mouseup(function() {
+ quotedText = getSelectionText("#fix-caption-code");
+ $("#edit-caption").val(quotedText);
+ });
+});