Added marker inputs to mark share counters #1234

Prior to that we used dom IDs to specify elements
where the share buttons and counts were placed. That
was problematic when multiple share buttons were used
on the page. This changeset introduces hidden inputs as
markers, which solves the problem of multiple IDs and
share counts for multiple buttons on the page.
Refactored the code to make it easier to read

No logic changes in this changeset, only structure, line breaks and indentation.