Browse Source

analytics

windhamdavid 10 years ago
parent
commit
67d6db4e90
3 changed files with 40 additions and 21 deletions
  1. 5 3
      inc/analytics.php
  2. 32 16
      js/analytics.js
  3. 3 2
      page-analytics.php

+ 5 - 3
inc/analytics.php

@@ -1,13 +1,12 @@
 <?php
 
 function dw_wik_places() {
-	$token_auth = 'd97e3e8f34071515ad1f6e345f6035af';
 
 	$url = "https://davidawindham.com/wik/";
 	$url .= "?module=API&method=UserCountry.getCity";
 	$url .= "&idSite=1&period=month&date=yesterday";
 	$url .= "&format=PHP&filter_limit=20";
-	$url .= "&token_auth=$token_auth";
+	$url .= "&token_auth=d97e3e8f34071515ad1f6e345f6035af";
 
 	$fetched = file_get_contents($url);
 	$content = unserialize($fetched);
@@ -19,7 +18,10 @@ function dw_wik_places() {
 	foreach ($content as $row) {
 	    $location = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
 	    $hits = $row['nb_visits'];
-	    print("<li class='list-group-item'>$location ( $hits hits )</li>");
+		$actions = $row['nb_actions'];
+		$logo = $row['logo'];
+		$length = $row['sum_visit_length'];
+	    print("<li class='list-group-item'><img src='https://davidawindham.com/wik/$logo'/> $location ( $hits hits ) <span class='badge'> $actions </span></li>");
 	}
 }
 

+ 32 - 16
js/analytics.js

@@ -1,20 +1,34 @@
-$(window).load(function(){
-	$('mapiframe').load(function() {
-		$('mapiframe').show()
-		$('#maploading').hide();
-	});
-	$('#maploading').show();
-	$('mapiframe').attr( "src", "https://davidawindham.com/wik/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=UserCountryMap&actionToWidgetize=realtimeMap&idSite=1&period=day&date=today&disableLink=1&widget=1&token_auth=d97e3e8f34071515ad1f6e345f6035af");
+$('.nav-toggle').on('touchstart click', function(e) {
+	e.preventDefault();
+	$( this ).toggleClass( 'active' );
 });
-  
-function calc_map_height() {
-	var the_height=
-		document.getElementById('map').contentWindow.
-		document.body.scrollHeight;
-		document.getElementById('map').height=
-	the_height;
-}
 
+$(function dw_hidenav() {
+	var headerHeight = $('.navbar').height();
+	$(window).on('scroll', { previousTop: 0 },
+		function() {
+		var currentTop = $(window).scrollTop();
+		if (currentTop < this.previousTop) {
+			if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
+					$('.navbar').addClass('visible');
+				} else {
+					$('.navbar').removeClass('visible fixed');
+				}
+		} 
+		else {
+			$('.navbar').removeClass('visible');
+			if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
+		}
+		this.previousTop = currentTop;
+		}  
+	);
+});
+
+
+
+
+
+/* -----------------------------
 (function( $ ) {
 	$.fn.timespent = function(options){
 		var urla = "https://davidawindham.com/wik/index.php?module=API&method=UserCountry.getCity&format=json&idSite=1&period=month&date=yesterday&expanded=1&token_auth=d97e3e8f34071515ad1f6e345f6035af";
@@ -39,6 +53,8 @@ function calc_map_height() {
 			});
 		});
 	};
-	
 	$('.time-spent').timespent();
 
+})( jQuery );
+
+------ SAVE FOR LATER  -------*/

+ 3 - 2
page-analytics.php

@@ -10,7 +10,8 @@
 					</ul>
 				</div>
 				<div class="col-sm-6">
-					<?php echo dw_wik()?>
+					<h4>Monthly</h4>
+					
 				</div>
 			</div>
 			<div class="row">
@@ -19,7 +20,7 @@
 			<div class="row">
 				<div class="col-sm-12">
 					<h4>Real Time Map</h4>
-					<iframe id="map" width="100%" scrolling="yes" onLoad="calc_map_height();" height="500px" frameborder="0"  style="background:transparent" src="https://davidawindham.com/wik/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=UserCountryMap&actionToWidgetize=realtimeMap&idSite=1&period=day&date=today&disableLink=1&widget=1&token_auth=d97e3e8f34071515ad1f6e345f6035af" /></iframe>
+					<iframe id="map" width="100%" height="500px" scrolling="yes" frameborder="0"  style="background:transparent" src="https://davidawindham.com/wik/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=UserCountryMap&actionToWidgetize=realtimeMap&idSite=1&period=day&date=today&disableLink=1&widget=1&token_auth=d97e3e8f34071515ad1f6e345f6035af" /></iframe>
 				</div>
 			</div>
 		</div>