function getSelection(input) {
    var selection;

    if ('selectionStart' in input) {
      // Modern browser with input or textarea.
      selection = {
        start: input.selectionStart,
        end: input.selectionEnd
      };
    } else {
      // Content editable or old IE textarea.
      selection = getOffsets(input);
    }

    return selection || {
      start: 0,
      end: 0
    };
  }
@getSelection: Gets the selection bounds of a focused textarea, input or
contentEditable node.
-@input: Look up selection bounds of this input
-@return {start: selectionStart, end: selectionEnd}