Skip to content

Update template for yandex counter#243

Open
axsapronov wants to merge 1 commit into
jazzband:mainfrom
axsapronov:yandex-update
Open

Update template for yandex counter#243
axsapronov wants to merge 1 commit into
jazzband:mainfrom
axsapronov:yandex-update

Conversation

@axsapronov

Copy link
Copy Markdown

Hi folks.

JS Code for Yandex Metrica was changed. This PR will change template.

(recreated PR #235 )

d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
<script type="text/javascript">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type="text/javascript" is unnecessary.

Suggested change
<script type="text/javascript">
<script>

<script type="text/javascript">
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is code from the Yandex documentation. Can you paste its source in the PR description, please?

This loop may be written using forEach instead to avoid index errors.

(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");

ym(%(counter_id)s, "init", %(options)s);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty line is likely not needed.

ym(%(counter_id)s, "init", %(options)s);

</script>
<noscript><div><img src="https://mc.yandex.ru/watch/%(counter_id)s" style="position:absolute; left:-9999px;" alt="" /></div></noscript>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not part of your PR, but would be nice to be brought up-to-date with standards (HTML5).

Suggested change
<noscript><div><img src="https://mc.yandex.ru/watch/%(counter_id)s" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<noscript><div><img src="https://mc.yandex.ru/watch/%(counter_id)s" style="position:absolute; left:-9999px;" alt=""></div></noscript>

@@ -12,25 +12,15 @@

COUNTER_ID_RE = re.compile(r'^\d{8}$')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another user reported in #244 that the counter id can now be longer that 8 characters. Can you also adjust this regular expression accordingly?

Suggested change
COUNTER_ID_RE = re.compile(r'^\d{8}$')
COUNTER_ID_RE = re.compile(r'^\d{8,10}$')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants