DotaNoobs main site.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
4.6 KiB

  1. {% extends "layout.html" %}
  2. {% block title %}Dota Noobs - Teamspeak{% endblock %}
  3. {% block head %}
  4. <script src="http://code.highcharts.com/3.0.1/highcharts.js"></script>
  5. <script type="text/javascript" src="http://github.highcharts.com/75c66eb3/modules/map.src.js"></script>
  6. <script type="text/javascript" src="http://github.highcharts.com/75c66eb3/modules/data.src.js"></script>
  7. <script type="text/javascript" src="{{ url_for('static', filename='js/world-map-shapes.js') }}"></script>
  8. <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/ts3_viewer.css') }}">
  9. {% endblock %}
  10. {% block content %}
  11. <div class="uk-grid">
  12. <div class="uk-width-large-1-2 uk-width-medium-1-1">
  13. <h3 class="uk-text-bold uk-text-center">Recent Activity</h3>
  14. <div class="uk-panel uk-panel-box" id="teamspeak_active_users"></div>
  15. <div class="uk-panel uk-panel-box" id="unique_clients"></div>
  16. <div class="uk-panel uk-panel-box" id="teamspeak_map"></div>
  17. <div class="uk-panel uk-panel-divider"></div>
  18. </div>
  19. <div class="uk-width-large-1-2 uk-width-medium-1-1">
  20. <h3 class="uk-text-bold uk-text-center">Current Status</h3>
  21. <div class="uk-panel uk-panel-space uk-panel-box uk-text-center">
  22. <a class="uk-button uk-button-success" href="ts3server://voice.dotanoobs.com">Connect</a>
  23. <a class="uk-button uk-button-primary" href="http://www.teamspeak.com/download">Download</a>
  24. <div class="uk-panel">
  25. {{ ts3_viewer() | safe }}
  26. </div>
  27. <h5>Server: voice.dotanoobs.com</h5>
  28. </div>
  29. </div>
  30. </div>
  31. {#
  32. <div>
  33. <div class="panel left" style="margin-left: 5em; width: 45%;">
  34. <h2 style="text-align: center">Last Week's Activity</h2>
  35. <div class="panel vertical" id="teamspeak_active_users"></div>
  36. <div class="panel vertical" id="unique_clients"></div>
  37. <div class="panel vertical" id="teamspeak_map"></div>
  38. </div>
  39. <div class="panel right" style="width: 30%; margin-right: 5em">
  40. <h2>Current Status</h2>
  41. <div class='panel vertical clickable' data-href="ts3server://voice.dotanoobs.com">
  42. <h5>Server: voice.dotanoobs.com</h5>
  43. </div>
  44. <div class='panel vertical'>
  45. {{ ts3_viewer() | safe }}
  46. </div>
  47. </div>
  48. </div>
  49. #}
  50. {% endblock %}
  51. {% block pagescripts %}
  52. {% cache 60*5 %}
  53. {% set teamspeak_data = getTeamspeakWindow() %}
  54. <script>
  55. $(document).ready(function() {
  56. $('#unique_clients').html("<h3>Number of unique clients: {{ num_unique_clients(teamspeak_data) }}</h3>");
  57. Highcharts.setOptions({
  58. global: {
  59. useUTC: false
  60. }
  61. });
  62. var chart = new Highcharts.Chart({
  63. chart: {
  64. renderTo: 'teamspeak_active_users',
  65. alignTicks: false,
  66. },
  67. title: {
  68. text: null,
  69. },
  70. xAxis: {
  71. type: 'datetime',
  72. dateTimeLabelFormats: {
  73. hour: '%l%P',
  74. day: '%a',
  75. },
  76. },
  77. yAxis: {
  78. title: {
  79. text: 'Active Users',
  80. },
  81. min: 0,
  82. tickInterval: 5,
  83. },
  84. tooltip: {
  85. formatter: function() {
  86. return Highcharts.dateFormat('%a %b %e @ %l%P', this.x) + ' <b>(' + this.y + ')</b>';
  87. }
  88. },
  89. plotOptions: {
  90. series: {
  91. marker: {
  92. enabled: false
  93. }
  94. }
  95. },
  96. series: [{
  97. showInLegend: false,
  98. type: 'areaspline',
  99. data: [
  100. {% for data in teamspeak_data %}
  101. [new Date('{{ timestamp_to_js_date(data.time) }}').valueOf(), {{ data.clients | count }}],
  102. {% endfor %}
  103. ],
  104. }],
  105. });
  106. var map_options = {
  107. chart: {
  108. renderTo: 'teamspeak_map',
  109. borderWidth: 1,
  110. zoomType: 'xy'
  111. },
  112. title: {
  113. text: 'Doobs by country'
  114. },
  115. legend: {
  116. align: 'left',
  117. verticalAlign: 'bottom',
  118. floating: true,
  119. layout: 'vertical',
  120. valueDecimals: 0
  121. },
  122. series: [{
  123. name: 'Active users',
  124. data: [],
  125. valueRanges: [{
  126. to: 1,
  127. color: 'rgba(19,64,117,0.05)'
  128. }, {
  129. from: 1,
  130. to: 5,
  131. color: 'rgba(19,64,117,0.4)'
  132. }, {
  133. from: 5,
  134. to: 10,
  135. color: 'rgba(19,64,117,0.5)'
  136. }, {
  137. from: 10,
  138. to: 20,
  139. color: 'rgba(19,64,117,0.6)'
  140. }, {
  141. from: 20,
  142. to: 30,
  143. color: 'rgba(19,64,117,0.8)'
  144. }, {
  145. from: 30,
  146. color: 'rgba(19,64,117,1)'
  147. }],
  148. states: {
  149. hover: {
  150. color: '#DD6E28'
  151. }
  152. }
  153. }]
  154. };
  155. // Populate the data points
  156. var data = {{ num_unique_clients_by_country(teamspeak_data) | tojson | safe }};
  157. var country_names = {{ country_abbreviation_mapping() | tojson | safe }};
  158. for (var key in shapes) {
  159. var num = 0;
  160. if (key in data) {
  161. num = data[key];
  162. }
  163. map_options.series[0].data.push({
  164. y: num,
  165. name: country_names[key],
  166. path: Highcharts.pathToArray(shapes[key]),
  167. states: {
  168. hover: {
  169. color: '#FF7F00'
  170. }
  171. }
  172. });
  173. }
  174. // Finalize the map
  175. var map = new Highcharts.Map(map_options);
  176. });
  177. </script>
  178. {% endcache %}
  179. {% endblock %}