1"use strict"; 2 3(function ($) { 4 5 let Deco_Social_Counters = { 6 count: 0, 7 8 getFollowers: function () { 9 let counts = $('.js__social-counts'); 10 11 counts.each(function () { 12 let self = $(this), 13 type = self.attr('data-type'), 14 val = self.attr('data-val'), 15 count = 0; 16 17 if (type === 'ig') { 18 $.get("https://www.instagram.com/arabicpost/?__a=1", function (data) { 19 let count = Deco_Social_Counters.abbrNum(data.graphql.user.edge_followed_by.count, 1); 20 $('.js__social-counts[data-type="ig"]').html(count); 21 }); 22 } else { 23 count = Deco_Social_Counters.abbrNum(val, 1); 24 self.html(count); 25 } 26 27 }); 28 29 setTimeout(function () { 30 counts.fadeIn(300); 31 counts.siblings().fadeIn(300); 32 }, 2000); 33 }, 34 35 abbrNum: function (number, decPlaces) { 36 // 2 decimal places => 100, 3 => 1000, etc 37 decPlaces = Math.pow(10, decPlaces); 38 39 // Enumerate number abbreviations 40 var abbrev = ["K", "M", "B", "T"]; 41 42 // Go through the array backwards, so we do the largest first 43 for (var i = abbrev.length - 1; i >= 0; i--) { 44 45 // Convert array index to "1000", "1000000", etc 46 var size = Math.pow(10, (i + 1) * 3); 47 48 // If the number is bigger or equal do the abbreviation 49 if (size <= number) { 50 // Here, we multiply by decPlaces, round, and then divide by decPlaces. 51 // This gives us nice rounding to a particular decimal place. 52 number = Math.round(number * decPlaces / size) / decPlaces; 53 54 // Handle special case where we round up to the next abbreviation 55 if ((number == 1000) && (i < abbrev.length - 1)) { 56 number = 1; 57 i++; 58 } 59 60 // Add the letter for the abbreviation 61 number += abbrev[i]; 62 63 // We are done... stop 64 break; 65 } 66 } 67 68 return number; 69 }, 70 71 72 init: function () { 73 if (!$('.js__social-counts').length) { 74 return false; 75 } 76 77 Deco_Social_Counters.getFollowers(); 78 } 79 }; 80 81 $(document).ready(function () { 82 Deco_Social_Counters.init(); 83 }); 84 85})(jQuery);
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.