Unresolved variable error in javascript files- Yandex

One month ago I asked this and got the solution.
I have similar issue now but adding javascript library to project settings didn't solve my issue.
http://devnet.jetbrains.net/thread/437086

Regarding to this: http://help.yandex.com/metrika/?id=1122008
I added following line to my javascript codes:

yaCounter123456.hit(url, title, referer);

But I get unresolved variable error.
How can I solve this error?
Thank you.

6 comments

Hi Ben,

Could you provide screenshots of the editor and your JavaScript libraries dialog?

Thanks,
Kirill

0

Thank you for answer.
I downloaded "watch.js" and added to javascript library.
You can find screenshots enclosed.


--------
Normally I embed this yandex code into my HTML pages:

-----------------
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
    (function (d, w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounter123456= new Ya.Metrika({id:123456, enableAll: true});
            } catch(e) { }
        });

        var n = d.getElementsByTagName("script")[0],
            s = d.createElement("script"),
            f = function () { n.parentNode.insertBefore(s, n); };
        s.type = "text/javascript";
        s.async = true;
        s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";

        if (w.opera == "[object Opera]") {
            d.addEventListener("DOMContentLoaded", f);
        } else { f(); }
    })(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="//mc.yandex.ru/watch/123456" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->



3.jpg

4.jpg

0

Thanks Ben,

At the moment IDE does not "see" any JavaScript symbols defined in HTML file from outside of that file. Workaround would be to extract Yandex.Metrika snippet into separate JavaScript file, but I'm not sure whether it is acceptable to require additional request to the server.

Feel free to report the bug to our tracker at http://youtrack.jetbrains.net/issues/WI

Kirill

0

Yes I need a workaround now. Anything that would suppress this red mark in editor :)
Is it possible to define something in project files whether than server request?

0

Well, you can create a dummy.js file which is not referenced anywhere in the project that contains a "stub" like

window.yaCounter123456 = ....

Kirill

0

I added that variable in dummy.js and added file into my project's javascript lirary settings. That's cool now.
Thank you

0

Please sign in to leave a comment.