Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ($) {
- /* Initialise Counters*/
- keywordSearchCounter(9292208, 'footballCounter');
- keywordSearchCounter(292410, 'tennisCounter');
- keywordSearchCounter(779180, 'chessCounter');
- function keywordSearchCounter(searchesPerMonth, elementId) {
- if($.type(searchesPerMonth) !== "number") return;
- if(searchesPerMonth === 0) return;
- console.log("function initialised for '" + elementId.toString() + "'");
- /* Do some math on searches */
- var daysInMonth = 28,
- hoursInDay = 24,
- minutesInHour = 60,
- secondsInMinute = 60;
- var searchesPerDay = searchesPerMonth / daysInMonth;
- var searches = searchesPerDay;
- console.log('per day: ' + searches);
- var searchesPerHour = searchesPerDay / hoursInDay;
- searches = searchesPerHour;
- console.log('per hour: ' + searches);
- var searchesPerMinute = searchesPerHour / minutesInHour;
- searches = searchesPerMinute;
- console.log('per minute: ' + searches);
- var searchesPerSecond = searchesPerMinute / secondsInMinute;
- searches = searchesPerSecond;
- console.log('per second: ' + searches);
- var interval = (1 / searches) * 1000;
- var counter = 0;
- console.log('interval set to: ' + interval);
- /* Set the counter speed */
- setInterval(function () {
- counter += 1;
- document.getElementById(elementId).innerHTML = counter;
- }, interval);
- }
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement