[livejournal] r22944: LJSUP-13509: Hit in lj-cut should be con...
Committer: vvasin
LJSUP-13509: Hit in lj-cut should be considered in the statistics. JS part has been provided.U trunk/htdocs/js/basic.js
Modified: trunk/htdocs/js/basic.js
===================================================================
--- trunk/htdocs/js/basic.js 2012-09-20 13:38:08 UTC (rev 22943)
+++ trunk/htdocs/js/basic.js 2012-09-20 13:43:35 UTC (rev 22944)
@@ -2298,3 +2298,31 @@
return enc.join("&");
}
};
+
+/**
+ * Object responsible for statistic integration
+ * @param {jQuery} $ jQuery
+ * @return {Object} Methods for statistic interation
+ */
+LJ.Stat = (function ($) {
+ var selector = '#hello-world', // block for statistic addition
+ el = null; // cached jquery element
+
+ /**
+ * Adds counter via inserting image on the page
+ * @param {String} img Image url
+ */
+ function addCounter( url ) {
+ var img = $('<img />', {
+ src: url,
+ alt: 'lj-counter'
+ });
+ // cache selector
+ el = el || $(selector);
+ el.append(img);
+ }
+
+ return {
+ addCounter: addCounter
+ };
+}(jQuery));
