textselection

This commit is contained in:
Sebastian Titz 2022-07-14 09:40:04 +02:00
parent 240a1f999a
commit 84535957c8
3 changed files with 37 additions and 10 deletions

View File

@ -1,5 +1,5 @@
$(function(){
$(document.body).bind('mouseup', function(e){
var selText = function(callback){
document.body.addEventListener('mouseup', function(e){
var selection;
if (window.getSelection) {
@ -8,6 +8,8 @@ $(function(){
selection = document.selection.createRange();
}
selection.toString() !== '' && alert('"' + selection.toString() + '" was selected at ' + e.pageX + '/' + e.pageY);
});
if(selection.toString() !== '') {
callback(selection.toString(),e.pageX, e.pageY);
}
});
};

2
selText.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
var selText=function(callback){document.body.addEventListener("mouseup",(function(e){var selection;window.getSelection?selection=window.getSelection():document.selection&&(selection=document.selection.createRange()),""!==selection.toString()&&callback(selection.toString(),e.pageX,e.pageY)}))};
//# sourceMappingURL=selText.min.js.map

23
selText.min.js.map Normal file
View File

@ -0,0 +1,23 @@
{
"version": 3,
"sources": [
"selText.js"
],
"names": [
"selText",
"callback",
"document",
"body",
"addEventListener",
"e",
"selection",
"window",
"getSelection",
"createRange",
"toString",
"pageX",
"pageY"
],
"mappings": "AAAA,IAAIA,QAAU,SAASC,UACrBC,SAASC,KAAKC,iBAAiB,WAAW,SAASC,GACjD,IAAIC,UAEAC,OAAOC,aACTF,UAAYC,OAAOC,eACVN,SAASI,YAClBA,UAAYJ,SAASI,UAAUG,eAGL,KAAzBH,UAAUI,YACXT,SAASK,UAAUI,WAAWL,EAAEM,MAAON,EAAEO",
"file": "selText.js"
}