[c_selection.js] If safari_mobile, get current selection from a previously created global variable
[c_sync.js] ref where the safari_mobile global is used
[c_text_view_comments.js] if safari_mobile update selection also on selectionChange event
[text_view_comments.html] if safari_mobile store a clone of the current selection on each selectionChange
set layout width to 99% to improve display
factorize safari mobile detection code
import chardet
import re
def to_unicode(input):
if type(input) == str:
res = None
encodings = ['utf8', 'latin1']
doc_enc = chardet.detect(input)['encoding']
if doc_enc:
encodings = [doc_enc,] + encodings
for encoding in encodings:
try:
res = unicode(input, encoding)
break;
except UnicodeDecodeError:
pass
if not res:
raise Exception('UnicodeDecodeError: could not decode')
return res
return input
# strip carriage returns
def strip_cr(input):
return re.sub('\r\n|\r|\n', '\n', input)