Difference between revisions of "MediaWiki:Common.js"

From Halon, SMTP software for hosting providers
Jump to: navigation, search
 
(38 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 +
var levels = [25, 50, 100, 200, 500, 1000, 2000, 5000, 10000];
 
$(document).ready(function() {
 
$(document).ready(function() {
 
   // Price
 
   // Price
Line 7: Line 8:
 
                 dataType: "json",
 
                 dataType: "json",
 
                 success: function(result) {
 
                 success: function(result) {
                         $("#price-user-25").text("$" + result["VSP-25"]);
+
                         $.each(levels, function (key, val) {
                        $("#price-25").text("$" + (25 * result["VSP-25"] * 12));
+
                            $("#price-user-" + val).text("$" + result["VSP-" + val]);
                        $("#price-user-50").text("$" + result["VSP-50"]);
+
                         });
                        $("#price-50").text("$" + (25 * result["VSP-50"] * 12));
 
                        $("#price-user-100").text("$" + result["VSP-100"]);
 
                        $("#price-100").text("$" + (100 * result["VSP-100"] * 12));
 
                        $("#price-user-500").text("$" + result["VSP-500"]);
 
                        $("#price-500").text("$" + (500 * result["VSP-500"] * 12));
 
                        $("#price-user-1000").text("$" + result["VSP-1000"]);
 
                        $("#price-1000").text("$" + (1000 * result["VSP-1000"] * 12));
 
                        $("#price-user-5000").text("$" + result["VSP-5000"]);
 
                        $("#price-5000").text("$" + (5000 * result["VSP-5000"] * 12));
 
                        $("#price-user-10000").text("$" + result["VSP-10000"]);
 
                         $("#price-10000").text("$" + (10000 * result["VSP-10000"] * 12));
 
 
                 },
 
                 },
 
         });
 
         });
 
   }
 
   }
   // whoson
+
   if ($("#price-10").length > 0) {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+
    var examples = [10, 40, 75, 150, 300, 750, 1500, 3000, 7500];
  ga.src = document.location.protocol + '//gateway02.whoson.ch/include.js?domain=www.halon.se';
+
    $.each(examples, function (key, val) {
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+
        pricecalc(val);
  setTimeout(function() { sWOResponse=''; if(typeof sWOTrackPage=='function')sWOTrackPage();}, 1000);
+
    });
 +
  }
 
});
 
});
var _gaq = _gaq || [];
+
 
_gaq.push(['_setAccount', 'UA-20664476-2']);
+
function pricecalc(users) {
_gaq.push(['_trackPageview']);
+
        $.ajax({
(function() {
+
                url: "/price.php?u=" + users,
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+
                dataType: "json",
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+
                success: function(result) {
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+
                        $("#price-"+users).text("$" + parseInt(result * users * 12));
})();
+
                },
 +
        });
 +
}
 +
 
 +
// Google Analytics
 +
  (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)
 +
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
 +
 
 +
  ga('create', 'UA-20664476-4', 'auto');
 +
  ga('send', 'pageview');

Latest revision as of 12:55, 18 January 2019

/* Any JavaScript here will be loaded for all users on every page load. */
var levels = [25, 50, 100, 200, 500, 1000, 2000, 5000, 10000];
$(document).ready(function() {
  // Price
  if ($("#price-user-25").length > 0) {
        $.ajax({
                url: "/price.php",
                dataType: "json",
                success: function(result) {
                        $.each(levels, function (key, val) {
                            $("#price-user-" + val).text("$" + result["VSP-" + val]);
                        });
                },
        });
  }
  if ($("#price-10").length > 0) {
     var examples = [10, 40, 75, 150, 300, 750, 1500, 3000, 7500];
     $.each(examples, function (key, val) {
         pricecalc(val);
     });
  }
});

function pricecalc(users) {
        $.ajax({
                url: "/price.php?u=" + users,
                dataType: "json",
                success: function(result) {
                        $("#price-"+users).text("$" + parseInt(result * users * 12));
                },
        });
}

// Google Analytics
  (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)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-20664476-4', 'auto');
  ga('send', 'pageview');