EvandroLG / selecting

:fishing_pole_and_fish: A library that allows you to access the text selected by the user
92 stars 12 forks source link

Return how much words was selected #16

Closed felquis closed 9 years ago

felquis commented 9 years ago
selecting(document, function(selector, otherInfos) {
  console.log(otherInfos.wordCount);
});

I think this is useful, to avoid the programar to write more code in the callback.

It'd be something like

selecting(document, function(selector) {
  console.log(selector.split(' ').length);
});

The first proposed solution, is so much elegant.

@EvandroLG what you think about a second parameter? Or, just transform the first parameter to a object, with a lot of helpful information.

selecting(document, function(selected) {
  console.log(selected.text);
  console.log(selected.wordCount);
});

Etc... would be awesome!