PageSourceSearch

https://dgbpool.com/js/main2o.js

js dgbpool.com collected 2026-10-06 15:04:07 UTC 19,231 bytes, 641 lines download raw bytes

1/* ===================================================================
2 * Main JS
3 * ------------------------------------------------------------------- */
4
5(function($) {
6
7    "use strict";
8    
9    var cfg = {
10        scrollDuration : 800, // smoothscroll duration
11
12    },
13
14    $WIN = $(window);
15
16    // Add the User Agent to the <html>
17    var doc = document.documentElement;
18    doc.setAttribute('data-useragent', navigator.userAgent);
19
20
21   /* Preloader
22    * -------------------------------------------------- */
23    var ssPreloader = function() {
24        
25        $("html").addClass('ss-preload');
26
27        $WIN.on('load', function() {
28
29            //force page scroll position to top at page refresh
30            $('html, body').animate({ scrollTop: 0 }, 'normal');
31
32            // will first fade out the loading animation 
33            $("#loader").fadeOut("slow", function() {
34            // will fade out the whole DIV that covers the website.
35                $("#preloader").delay(300).fadeOut("slow");
36            }); 
37            
38            // for hero content animations 
39            $("html").removeClass('ss-preload');
40            $("html").addClass('ss-loaded');
41        
42        });
43    };
44
45
46   /* Menu on Scrolldown
47    * ------------------------------------------------------ */
48    var ssMenuOnScrolldown = function() {
49        
50        var hdr= $('.s-header'),
51            hdrTop = $('.s-header').offset().top;
52
53        $WIN.on('scroll', function() {
54
55            if ($WIN.scrollTop() > hdrTop) {
56                hdr.addClass('sticky');
57            }
58            else {
59                hdr.removeClass('sticky');
60            }
61
62        });
63    };
64
65
66   /* Mobile Menu
67    * ---------------------------------------------------- */ 
68    var ssMobileMenu = function() {
69
70        var toggleButton = $('.header-menu-toggle'),
71            nav = $('.header-nav-wrap'),
72		    shead = $('.s-header');
73
74        toggleButton.on('click', function(event){
75            event.preventDefault();
76
77            toggleButton.toggleClass('is-clicked');
78            nav.slideToggle(); shead.toggleClass('opaque');
79        });
80
81        if (toggleButton.is(':visible')) nav.addClass('mobile');
82
83        $WIN.on('resize', function() {
84            if (toggleButton.is(':visible')) nav.addClass('mobile');
85            else nav.removeClass('mobile');
86        });
87
88        nav.find('a').on("click", function() {
89
90            if (nav.hasClass('mobile')) {
91                toggleButton.toggleClass('is-clicked');
92                nav.slideToggle();
93            }
94        });
95
96    };
97
98
99   /* Highlight the current section in the navigation bar
100    * ------------------------------------------------------ */
101    var ssWaypoints = function() {
102
103        var sections = $(".target-section"),
104            navigation_links = $(".header-nav-wrap li a");
105
106        sections.waypoint( {
107
108            handler: function(direction) {
109
110                var active_section;
111
112                active_section = $('section#' + this.element.id);
113
114                if (direction === "up") active_section = active_section.prevAll(".target-section").first();
115
116                var active_link = $('.header-nav-wrap li a[href="#' + active_section.attr("id") + '"]');
117
118                navigation_links.parent().removeClass("current");
119                active_link.parent().addClass("current");
120            },
121            offset: '25%'
122        });
123    };
124
125
126   /* Slick slider
127    * ------------------------------------------------------ */
128    var ssSlickSlider = function() {
129        
130        $('.about-desc__slider').slick({
131			prevArrow: '<a class="slide-arrowab prev-arrowab"></a>',
132            nextArrow: '<a class="slide-arrowab next-arrowab"></a>',
133            arrows: false,
134            dots: true,
135            infinite: false,
136            slidesToShow: 4,
137            slidesToScroll: 1,
138            pauseOnFocus: true,
139			autoplay: false,
140            autoplaySpeed: 7500,
141            responsive: [
142                {
143                    breakpoint: 1401,
144                    settings: {
145						arrows: true,
146                        slidesToShow: 3,
147                        slidesToScroll: 1
148                    }
149                },
150                {
151                    breakpoint: 1151,
152                    settings: {
153                        slidesToShow: 2,
154                        slidesToScroll: 1,
155						infinite: true,
156                    }
157                },
158                {
159                    breakpoint: 701,
160                    settings: {
161                        slidesToShow: 1,
162                        slidesToScroll: 1,
163						infinite: true,
164                    }
165                }
166            ]
167        });
168
169        $('.testimonials__slider').slick({
170			prevArrow: '<a class="slide-arrow prev-arrow"></a>',
171            nextArrow: '<a class="slide-arrow next-arrow"></a>',
172            arrows: true,
173            dots: true,
174            infinite: false,
175            slidesToShow: 2,
176            slidesToScroll: 1,
177            pauseOnFocus: true,
178			autoplay: false,
179            autoplaySpeed: 5000,
180            responsive: [
181                {
182                    breakpoint: 1151,
183                    settings: {
184						arrows: false,
185                        slidesToShow: 2,
186                        slidesToScroll: 1,
187						infinite: true,
188                    }
189                },
190				{
191                    breakpoint: 701,
192                    settings: {
193						arrows: false,
194                        slidesToShow: 1,
195                        slidesToScroll: 1,
196						infinite: true,
197                    }
198                }
199            ]
200        });
201    };
202	
203	
204	 /* Stat Counter
205    * ------------------------------------------------------ */
206    var ssStatCount = function(el) {
207
208        var statSection = $(".s-stats"),
209        stats = $(el);
210
211        statSection.waypoint({
212
213            handler: function(direction) {
214
215                if (direction === "down") {
216
217                    stats.each(function () {
218                        var $this = $(this);
219
220                        $({ Counter: 0 }).animate({ Counter: $this.text() }, {
221                            duration: 3000,
222                            easing: 'swing',
223                            step: function (curValue) {
224                                $this.text(Math.ceil(curValue));
225                            }
226                        });
227                    });
228
229                } 
230               
231            },
232
233            offset: "90%"
234
235        });
236    };
237
238
239   /* Smooth Scrolling
240    * ------------------------------------------------------ */
241    var ssSmoothScroll = function() {
242        
243        $('.smoothscroll').on('click', function (e) {
244            var target = this.hash,
245                $target = $(target);
246            
247                e.preventDefault();
248                e.stopPropagation();
249
250            $('html, body').stop().animate({
251                'scrollTop': $target.offset().top
252            }, cfg.scrollDuration, 'swing').promise().done(function () {
253				
254			history.pushState(null, null, target);
255
256            });
257        });
258		
259		$('.smoothscrollup').on('click', function (e) {
260            var target = this.hash,
261                $target = $(target);
262            
263                e.preventDefault();
264                e.stopPropagation();
265
266            $('html, body').stop().animate({
267                'scrollTop': $target.offset().top -100
268            }, cfg.scrollDuration, 'swing').promise().done(function () {
269				
270			history.pushState(null, null, target);
271
272            });
273        });
274		
275		$('.ssbc').on('click', function (e) {
276            var target = this.hash,
277                $target = $(target);
278            
279                e.preventDefault();
280                e.stopPropagation();
281
282            $('html, body').stop().animate({
283                'scrollTop': $target.offset().top +255
284            }, cfg.scrollDuration, 'swing').promise().done(function () {
285				
286			history.pushState(null, null, target);
287
288            });
289        });
290		
291		$('.ssbcm').on('click', function (e) {
292            var target = this.hash,
293                $target = $(target);
294            
295                e.preventDefault();
296                e.stopPropagation();
297
298            $('html, body').stop().animate({
299                'scrollTop': $target.offset().top +435
300            }, cfg.scrollDuration, 'swing').promise().done(function () {
301				
302			history.pushState(null, null, target);
303
304            });
305        });
306
307    };
308
309
310   /* Animate On Scroll
311    * ------------------------------------------------------ */
312    var ssAOS = function() {
313        
314        AOS.init( {
315            offset: 200,
316            duration: 500,
317            easing: 'ease-in-sine',
318            delay: 100,
319            once: false,
320        });
321
322    };
323
324
325    /* Back to Top
326    * ------------------------------------------------------ */
327    var ssBackToTop = function() {
328        
329    var pxShow      = 500,
330        goTopButton = $(".go-top");
331
332        if ($(window).scrollTop() >= pxShow) goTopButton.addClass('link-is-visible');
333
334        $(window).on('scroll', function() {
335            if ($(window).scrollTop() >= pxShow) {
336                if(!goTopButton.hasClass('link-is-visible')) goTopButton.addClass('link-is-visible')
337            } else {
338                goTopButton.removeClass('link-is-visible')
339            }
340        });
341    };
342	
343	
344/* include html */
345function includeHTML() {
346  var z, i, elmnt, file, xhttp;
347  z = document.getElementsByTagName("*");
348  for (i = 0; i < z.length; i++) {
349    elmnt = z[i];
350    file = elmnt.getAttribute("includeHTML");
351    if (file) {
352      xhttp = new XMLHttpRequest();
353      xhttp.onreadystatechange = function() {
354        if (this.readyState == 4) {
355          if (this.status == 200) {elmnt.innerHTML = this.responseText;}
356          if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
357          elmnt.removeAttribute("includeHTML");
358          includeHTML();
359        }
360      }      
361      xhttp.open("GET", file, true);
362      xhttp.send();
363      return;
364    }
365  }
366};
367
368// set Cookie
369function setCookie(name, value) {
370  var d = new Date();
371  d.setTime(d.getTime() + (15 * 24 * 60 * 60 * 1000)); // 15 days
372  document.cookie = name + "=" + value + "; expires=" + d.toGMTString() + "; path=/";
373}
374
375// get Cookie
376function getCookie(name) {
377  var nameEQ = name + "=";
378  var ca = document.cookie.split(';');
379  for(var i=0;i < ca.length;i++) {
380    var c = ca[i];
381    while (c.charAt(0)==' ') c = c.substring(1,c.length);
382    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
383  }
384  return null;
385}
386
387/* display year difference from  2014 to current year*/
388function displayYearDifference() {
389  const currentDate = new Date();
390  const currentYear = currentDate.getFullYear();
391  const startYear = 2014;
392  const yearDifference = currentYear - startYear;
393  // Get all span elements with class "year-diff"
394  var spanElements = document.querySelectorAll('.year-diff');
395
396  // Append the year difference to each span element
397  spanElements.forEach(function(span) {
398    span.textContent = yearDifference;
399  });
400  // Get the div element with id "years-surpassed"
401  const yearSurpassedDiv  = document.getElementById('years-surpassed');
402  yearSurpassedDiv.innerText = yearDifference;
403  ssStatCount(yearSurpassedDiv);
404}
405
406// display the current block count
407function displayBlockCount() {
408  fetch('https://chainz.cryptoid.info/dgb/api.dws?q=getblockcount')
409    .then(response => response.text())
410    .then(data => {
411      console.log(data);
412      const blockCount = parseInt(data);
413      var blockCountSpan  = document.getElementById('block-count');
414      blockCountSpan.innerHTML = blockCount;
415      ssStatCount(blockCountSpan);
416    })
417    .catch(error => console.log(error));
418}
419
420let totalDownloadCount = 0;
421// display the total download count for the Digibyte and Digibyte Core nodes
422function displayDigibyteNodeDownloadCount() {
423  const nodeDownloadCountDiv = document.getElementById('node-download-count');
424
425  async function fetchDownloadCount(repoName, cookieName) {
426    let totalDownloadCount = 0;
427
428    try {
429      if (getCookie(cookieName)) {
430        totalDownloadCount = parseInt(getCookie(cookieName));
431      } else {
432        const response = await fetch(`https://api.github.com/repos/${repoName}/releases`);
433        const data = await response.json();
434
435        data.forEach((release) => {
436          release.assets.forEach((asset) => {
437            totalDownloadCount += asset.download_count;
438          });
439        });
440
441        setCookie(cookieName, totalDownloadCount);
442      }
443    } catch (error) {
444      console.error(`Error fetching ${repoName} download count: ${error.message}`);
445    }
446
447    return totalDownloadCount;
448  }
449
450  async function updateNodeDownloadCount() {
451    const digibyteCount = await fetchDownloadCount('digibyte/digibyte', 'digibyte-node-download');
452    const digibyteCoreCount = await fetchDownloadCount('digibyte-core/digibyte', 'digibytecore-node-download');
453
454    totalDownloadCount = digibyteCount + digibyteCoreCount;
455    nodeDownloadCountDiv.innerText = totalDownloadCount;
456    ssStatCount(nodeDownloadCountDiv);
457  }
458
459  updateNodeDownloadCount();
460}
461
462// Append the copyright year to the footer
463function appendCopyrightDate() {
464  const currentYear = new Date().getFullYear();
465  const copyrightText = `DigiByte 2013 - ${currentYear}`;
466
467  // Get/Set the span element with id "copyright-year"
468  const spanElement = document.getElementById('copyright-year');
469  spanElement.textContent = copyrightText;
470}
471   /* Initialize
472    * ------------------------------------------------------ */
473    (function clInit() {
474        ssPreloader();
475        ssMenuOnScrolldown();
476        ssMobileMenu();
477        ssWaypoints();
478        ssSlickSlider();
479        ssSmoothScroll();
480        ssAOS();
481        ssBackToTop();
482		    includeHTML();
483        displayYearDifference();
484        displayBlockCount();
485        displayDigibyteNodeDownloadCount();
486        appendCopyrightDate();
487    })();
488
489})(jQuery);
490
491/* Clickable language menu */
492function lmenu() {
493  document.getElementById("lddown").classList.toggle("show");
494}
495
496window.onclick = function(event) {
497  if (!event.target.matches('.dropbtn')) {
498    var dropdowns = document.getElementsByClassName("dropdown-content");
499    var i;
500    for (i = 0; i < dropdowns.length; i++) {
501      var openDropdown = dropdowns[i];
502      if (openDropdown.classList.contains('show')) {
503        openDropdown.classList.remove('show'),
504		openDropdown.classList.add('hide')
505      }
506    }
507  }
508}
509
510/* Home button script */
511function homeButton() {
512var toggleButton = $('.header-menu-toggle'),
513             nav = $('.header-nav-wrap'),
514		   shead = $('.s-header');
515	
516shead.removeClass('opaque');
517     
518if (toggleButton.hasClass('is-clicked')) {
519	toggleButton.removeClass('is-clicked');
520	nav.slideToggle();
521}
522}
523
524/* Remove pace (Run once) */
525window.addEventListener("load", function(){
526	setTimeout(function() {
527        $('body').addClass('nopace');
528    }, 1000);
529});
530
531/* lang menu text */
532var path = location.pathname;
533var string = location.search.substring(1);
534
535    if (string.includes ("en"))
536		document.getElementById("lmenuname").innerHTML = "English"+"&nbsp;&#9662;";
537
538    else if (path.includes ("af"))
539		document.getElementById("lmenuname").innerHTML = "Afrikaans"+"&nbsp;&#9662;";
540
541    else if (path.includes ("cs"))
542		document.getElementById("lmenuname").innerHTML = "Čeština"+"&nbsp;&#9662;";
543
544    else if (path.includes ("da"))
545		document.getElementById("lmenuname").innerHTML = "Dansk"+"&nbsp;&#9662;";
546
547    else if (path.includes ("de"))
548		document.getElementById("lmenuname").innerHTML = "Deutsch"+"&nbsp;&#9662;";
549
550    else if (path.includes ("es"))
551		document.getElementById("lmenuname").innerHTML = "Español"+"&nbsp;&#9662;";
552
553    else if (path.includes ("fr"))
554		document.getElementById("lmenuname").innerHTML = "Français"+"&nbsp;&#9662;";
555
556    else if (path.includes ("hr"))
557		document.getElementById("lmenuname").innerHTML = "Hrvatski"+"&nbsp;&#9662;";
558
559    else if (path.includes ("id"))
560		document.getElementById("lmenuname").innerHTML = "Indonesia"+"&nbsp;&#9662;";
561
562    else if (path.includes ("it"))
563		document.getElementById("lmenuname").innerHTML = "Italiano"+"&nbsp;&#9662;";
564
565    else if (path.includes ("sw"))
566		document.getElementById("lmenuname").innerHTML = "Kiswahili"+"&nbsp;&#9662;";
567
568    else if (path.includes ("hu"))
569		document.getElementById("lmenuname").innerHTML = "Magyar"+"&nbsp;&#9662;";
570
571    else if (path.includes ("ms"))
572		document.getElementById("lmenuname").innerHTML = "Melayu"+"&nbsp;&#9662;";
573
574    else if (path.includes ("nl"))
575		document.getElementById("lmenuname").innerHTML = "Nederlands"+"&nbsp;&#9662;";
576
577    else if (path.includes ("nb"))
578		document.getElementById("lmenuname").innerHTML = "Norsk"+"&nbsp;&#9662;";
579
580    else if (path.includes ("fil"))
581		document.getElementById("lmenuname").innerHTML = "Pilipino"+"&nbsp;&#9662;";
582
583    else if (path.includes ("pl"))
584		document.getElementById("lmenuname").innerHTML = "Polski"+"&nbsp;&#9662;";
585
586    else if (path.includes ("pt"))
587		document.getElementById("lmenuname").innerHTML = "Português"+"&nbsp;&#9662;";
588
589    else if (path.includes ("ro"))
590		document.getElementById("lmenuname").innerHTML = "Română"+"&nbsp;&#9662;";
591
592    else if (path.includes ("sq"))
593		document.getElementById("lmenuname").innerHTML = "Shqip"+"&nbsp;&#9662;";
594
595    else if (path.includes ("sl"))
596		document.getElementById("lmenuname").innerHTML = "Slovenščina"+"&nbsp;&#9662;";
597
598    else if (path.includes ("fi"))
599		document.getElementById("lmenuname").innerHTML = "Suomi"+"&nbsp;&#9662;";
600
601    else if (path.includes ("sv"))
602		document.getElementById("lmenuname").innerHTML = "Svenska"+"&nbsp;&#9662;";
603
604    else if (path.includes ("vi"))
605		document.getElementById("lmenuname").innerHTML = "Tiếng Việt"+"&nbsp;&#9662;";
606
607    else if (path.includes ("tr"))
608		document.getElementById("lmenuname").innerHTML = "Türkçe"+"&nbsp;&#9662;";
609
610    else if (path.includes ("ru"))
611		document.getElementById("lmenuname").innerHTML = "Русский"+"&nbsp;&#9662;";
612
613    else if (path.includes ("bg"))
614		document.getElementById("lmenuname").innerHTML = "български"+"&nbsp;&#9662;";
615
616    else if (path.includes ("el"))
617		document.getElementById("lmenuname").innerHTML = "Ελληνικά"+"&nbsp;&#9662;";
618
619    else if (path.includes ("hi"))
620		document.getElementById("lmenuname").innerHTML = "हिन्दी"+"&nbsp;&#9662;";
621
622    else if (path.includes ("th"))
623		document.getElementById("lmenuname").innerHTML = "ไทย"+"&nbsp;&#9662;";
624
625    else if (path.includes ("ja"))
626		document.getElementById("lmenuname").innerHTML = "日本語"+"&nbsp;&#9662;";
627
628    else if (path.includes ("ko"))
629		document.getElementById("lmenuname").innerHTML = "한국어"+"&nbsp;&#9662;";
630
631    else if (path.includes ("zh"))
632		document.getElementById("lmenuname").innerHTML = "简体中文"+"&nbsp;&#9662;";
633
634    else if (path.includes ("ar"))
635		document.getElementById("lmenuname").innerHTML = "العربية"+"&nbsp;&#9662;";
636
637    else if (path.includes ("fa"))
638		document.getElementById("lmenuname").innerHTML = "فارسی"+"&nbsp;&#9662;";
639
640    else
641		document.getElementById("lmenuname").innerHTML = "English"+"&nbsp;&#9662;";

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.