Skip to content

Commit

Permalink
Add: page view text
Browse files Browse the repository at this point in the history
  • Loading branch information
qinwf committed May 22, 2016
1 parent 2500f37 commit e37cdb4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@ <h3 class="masthead-title">

<footer class="footer">
<small>
&copy; <time datetime="{{ site.time | date_to_xmlschema }}">{{ site.time | date: '%Y' }}</time>. RWeekly.org
&copy; 2016 RWeekly.org &nbsp;
</small>
</footer>
</div>


<script>
page_view = document.getElementById("page_view");
if (page_view){
var xhr = new XMLHttpRequest();
xhr.open("POST","https://page.rweekly.org");
xhr.setRequestHeader("Content-Type","application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var myArr = JSON.parse(xhr.responseText);
page_view.innerHTML = myArr.hit + " views" ;
}
};
xhr.send(JSON.stringify({ page:document.location.host + document.location.pathname }));
}
</script>

<script>

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
Expand Down
1 change: 1 addition & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<h1 class="post-title">{{ page.title }}</h1>
<time datetime="{{ page.date | date_to_xmlschema }}" class="post-date">{{ page.date | date_to_string }}</time>
{{ content }}
<p><small id="page_view">&nbsp;</small></p>
</article>

{% if site.related_posts != empty %}
Expand Down
2 changes: 2 additions & 0 deletions draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ Updates from R Core.
[R](https://www.r-project.org/) is a free software environment for statistical computing and graphics.

**R Weekly** is openly developed [on GitHub](https://github.com/rweekly/rweekly.org).

<p><small id="page_view">&nbsp;</small></p>
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h1 class="post-title">
<time datetime="{{ post.date | date_to_xmlschema }}" class="post-date">{{ post.date | date_to_string }}</time>

{{ post.content }}
<p><small id="page_view">&nbsp;</small></p>
</article>
{% endfor %}
</div>
Expand All @@ -31,3 +32,4 @@ <h1 class="post-title">
<span class="pagination-item newer">Newer</span>
{% endif %}
</div>

0 comments on commit e37cdb4

Please sign in to comment.