tag-youre-it/content_script.js

50 lines
1 KiB
JavaScript
Raw Normal View History

$(document).ready(function () {
2015-09-26 21:06:24 +02:00
function processSelection () {
var focused = document.activeElement;
var selectedText;
if (focused) {
try {
selectedText = focused.value.substring(
focused.selectionStart, focused.selectionEnd);
} catch (err) {
}
}
if (selectedText == undefined) {
var sel = window.getSelection();
var selectedText = sel.toString();
}
console.log(selectedText);
}
2015-09-26 21:06:24 +02:00
document.addEventListener('click', function(evt) {
if (!document.hasFocus()) {
return true;
}
processSelection();
// evt.stopPropagation();
// evt.preventDefault();
}, false);
2015-09-26 21:06:24 +02:00
// var popoverContent;
2015-09-26 20:48:26 +02:00
2015-09-26 21:06:24 +02:00
// $.get('test-menu-content.html', function (data) {
// popoverContent = data;
// contentReady();
// });
2015-09-26 20:48:26 +02:00
2015-09-26 21:06:24 +02:00
// function contentReady () {
// $('.selected').popover({
// title: "Please select a semantic tag",
2015-09-26 20:48:26 +02:00
2015-09-26 21:06:24 +02:00
// content: popoverContent,
2015-09-26 20:48:26 +02:00
2015-09-26 21:06:24 +02:00
// html: true,
2015-09-26 20:48:26 +02:00
2015-09-26 21:06:24 +02:00
// placement: 'auto'
// });
// $('.selected').popover('show');
// }
2015-09-26 20:48:26 +02:00
});