Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Counter Download ModuleCounter Download Module
Previous
 
Next
New Post
10/30/2010 2:26 AM
 
Hi. can you tell me how can i have a counter module like the one you have on dotnetnuke page that will display numbers from a custom datasource?
 
New Post
10/30/2010 5:46 AM
 
if you look at the source code of the home page, you will find this piece of code:

<div id="dnn_ctr5587_Display_UP">

 

<script type="text/javascript">

var interval = .1;

var counter, count = 0, updatedate;

$(document).ready(function () {

$.ajax({

type: "GET",

url: "/DesktopModules/Ticker/TickerXml.aspx",

dataType: "xml",

success: function (xml) {

$(xml).find("Ticker").each(function () {

var $ticker = $(this);

counter = $ticker.find('counter').text();

updatedate = $ticker.find('updateddate').text();

});

}

});

if(typeof(counter) == "undefined") {

counter = 5568487;

updatedate = '10/20/2010 12:00:00 AM';

}

/*counter = 5408328;

updatedate = '9/23/2010 1:38:40 PM';*/

setTimeout(function () { getcounter(); }, 250);

setInterval("getcounter();", interval * 60 * 1000);

});

function addCommas(number)

{

number += '';

x = number.split('.');

x1 = x[0];

x2 = x.length > 1 ? '.' + x[1] : '';

var rgx = /(\d+)(\d{3})/;

while (rgx.test(x1))

{

x1 = x1.replace(rgx, '$1' + ',' + '$2');

}

return x1 + x2;

}

function getcounter()

{

var currenttime = new Date();

updatedate = new Date(Date.parse(updatedate));

var seconds = calculate(updatedate, currenttime);

var addedupdates = Math.floor(seconds / (60*interval));

if (count == 0)

{

count = counter;

count = parseInt(count) + parseInt(addedupdates);

}

counter = addCommas(count);

var counterarray = counter.split(",");

var html = '';

for(var i=0; i<counterarray.length; i++)

{

html += '<span>'+counterarray[i]+'</span>';

}

$(".downloadCounter").html('Over <strong>'+html+'</strong> Downloads');

count++;

}

function calculate(update, current) {

current = new Date(current);

update = new Date(update);

var sec = current.getTime() - update.getTime();

if (isNaN(sec)) {

// input data is incorrect!");

$(".downloadCounter").html('Over <strong>5</strong> <strong>500</strong> <strong>000</strong> Downloads');

}

var second = 1000, minute = 60 * second, hour = 60 * minute, day = 24 * hour;

var days = Math.floor(sec / day);

sec -= days * day;

var hours = Math.floor(sec / hour);

sec -= hours * hour;

var minutes = Math.floor(sec / minute);

sec -= minutes * minute;

var seconds = Math.floor(sec / second);

var totalsecond = seconds + (minutes * 60) + (60 * 60 * hours) + (60 * 60 * hours * days);

return totalsecond;

}

</script>

<div class="downloadCounter"><strong><span>5</span><span>444</span>000</strong></div>

</div><div id="dnn_ctr5587_Display_UP_Prog" style="display:none;">

<img src="/images/progressbar.gif" alt="ProgressBar" style="border-width:0px;" />

</div>

</div>

where /DesktopModules/Ticker/TickerXml.aspx returns something like this:

  <?xml version="1.0" encoding="utf-8" ?>
 <Root>
 <Ticker>
  <counter>5583710</counter>
  <updateddate>10/30/2010 2:33:09 AM</updateddate>
  </Ticker>
  </Root>

so, you would have to have your own serverside process that returns the data, then you can use jquery in combination with a timer to update counts every second or so.


Erik van Ballegoij, Former DNN Corp. Employee and DNN Expert

DNN Blog | Twitter: @erikvb | LinkedIn: Erik van Ballegoij on LinkedIn

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Counter Download ModuleCounter Download Module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out