{"version":3,"sources":["../../../../dev/j/v2/pages/windows-10-antivirus.js"],"names":["avm","require","renderGraph","data","processedData","$","name","push","week","users","locale","length","splice","$users","html","thMil","x","domain","map","d","y","d3","max","svg","append","attr","call","xAxis","yAxis","select","selectAll","insert","style","$window","on","$around","offset","top","height","window","pageYOffset","innerHeight","revealStats","avastGlobals","web","substring","customLocales","$global","$local","$additional","number","value","toString","separator","numberThousandSeparator","arr","usersLength","str","i","Math","ceil","unshift","j","margin","right","bottom","left","width","scale","ordinal","rangeRoundBands","linear","range","axis","orient","enter","rangeBand","transition","delay","duration","ease","indexOf","hide","toUpperCase","xhr","XMLHttpRequest","open","setRequestHeader","onreadystatechange","readyState","status","JSON","parse","responseText","console","log","statusText","send","sliderMyCarousel","tns","container","controlsContainer","controlsPosition","controls","navPosition","mouseDrag","speed","fixedWidth","preventScrollOnTouch","responsive","576","center","768","items","slideBy","1280","1366","1600","sliderMyCarouselVariantB"],"mappings":"CAAA,WACC,YACQA,KAAIC,QAAQ,WAGrB,WACC,YA8HA,SAASC,GAAYC,GAEpB,GAAIC,KACMC,GAAE,YACZ,KAAK,GAAIC,KAAQH,GAChBC,EAAcG,MACbC,KAAMF,EACNG,MAAON,EAAKG,GAAMI,GAAQD,OAKxBL,GAAcO,OAAS,KAC1BP,EAAgBA,EAAcQ,OAAOR,EAAcO,OAAS,KAI7DE,EAAOC,KAAKC,EAAMX,EAAcA,EAAcO,OAAS,GAAGF,QAG1DO,EAAEC,OAAOb,EAAcc,IAAI,SAASC,GACnC,MAAOA,GAAEX,QAGVY,EAAEH,QAAQ,EAAGI,GAAGC,IAAIlB,EAAe,SAASe,GAC3C,MAAOA,GAAEV,MAAQ,EAAIU,EAAEV,UAGxBc,EAAIC,OAAO,KACTC,KAAK,QAAS,UAEdA,KAAK,YAAa,sBAElBC,KAAKC,GAEPJ,EAAIC,OAAO,KACTC,KAAK,QAAS,UACdA,KAAK,YAAa,mBAClBC,KAAKE,GAGPP,GAAGQ,OAAO,WACRC,U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,EAAYiC,OACZlC,EAAOkC,SAGPxE,EAASA,EAAOyE,cAChBpC,EAAQmC,OAGT,IAAIE,GAAM,GAAIC,eACdD,GAAIE,KAAK,MArGF,sDAsGPF,EAAIG,iBAAiB,mBAAoB,kBACzCH,EAAII,mBAAqB,WACD,IAAnBJ,EAAIK,aAGW,MAAfL,EAAIM,OACPxF,EAAYyF,KAAKC,MAAMR,EAAIS,eAE3BC,QAAQC,IAAI,aAAcX,EAAIM,OAAQN,EAAIY,cAG5CZ,EAAIa,SAwEL,IAAIC,kBAAmBC,KACtBC,UAAW,2BACXC,kBAAmB,oCACnBC,iBAAkB,SAClBC,UAAU,EACVC,YAAa,SACbC,WAAW,EACXC,MAAO,IACPC,WAAY,IACZC,qBAAsB,OACtBC,YACCC,KACCC,QAAQ,GAETC,KACCC,MAAO,EACPC,QAAS,EACTX,UAAU,EACVQ,QAAQ,GAETI,MACCR,WAAY,KAEbS,MACCT,WAAY,KAEbU,MACCV,WAAY,OASf,IAAItG,EAAE,kDAAkDM,OAAS,EAEhE,GAAI2G,0BAA2BnB,KAC9BC,UAAW,iDACXC,kBAAmB,0DACnBC,iBAAkB,SAClBC,UAAU,EACVC,YAAa,SACbC,WAAW,EACXC,MAAO,IACPC,WAAY,IACZC,qBAAsB,OACtBC,YACCC,KACCC,QAAQ,GAETC,KACCC,MAAO,EACPC,QAAS,EACTX,UAAU,EACVQ,QAAQ,GAETI,MACCR,WAAY,KAEbS,MACCT,WAAY,KAEbU,MACCV,WAAY","file":"windows-10-antivirus.js","sourcesContent":["(function() {\n\t'use strict';\n\tvar $ = avm.require('cash');\n})();\n\n(function() {\n\t'use strict';\n\n\t/* ----------------------------------\n\t\tDynamic section - D3 graph\n\t\t---------------------------------- */\n\tvar data,\n\t\t$ = avm.require('cash'),\n\t\t$window = $(window),\n\t\tlocale = window.avastGlobals.web.locale.substring(3),\n\t\tcustomLocales = ['us', 'fr', 'br', 'ru'],\n\t\turl = '/api/v1/threat-stats?from=2015-01-01&to=2050-07-07',\n\t\t$around = $('#around'),\n\t\t$global = $('.js-global'),\n\t\t$local = $('.js-local'),\n\t\t$additional = $('.js-additional'),\n\t\t$users = $('.js-users'),\n\t\tthMil = function(number) {\n\t\t\tvar users = number.toString(),\n\t\t\t\tseparator = avastGlobals.web.numberThousandSeparator,\n\t\t\t\tarr = [],\n\t\t\t\tusersLength = users.length,\n\t\t\t\tstr = '',\n\t\t\t\tvalue;\n\n\t\t\tfor (var i = Math.ceil(usersLength / 3); i > 0; i--) {\n\t\t\t\tvalue = users.substring(usersLength - 3, usersLength);\n\t\t\t\tusersLength -= 3;\n\t\t\t\tarr.unshift(value);\n\t\t\t}\n\t\t\tfor (var j = 0; j < arr.length; j++) {\n\t\t\t\tstr += arr[j] + separator;\n\t\t\t}\n\t\t\tif (separator === '') {\n\t\t\t\treturn str.substring(0, str.length + 1);\n\t\t\t} else {\n\t\t\t\treturn str.substring(0, str.length - 1);\n\t\t\t}\n\t\t},\n\t\t// Graph\n\t\tmargin = {\n\t\t\ttop: 20,\n\t\t\tright: 0,\n\t\t\tbottom: 80,\n\t\t\tleft: 150\n\t\t},\n\t\twidth = 900 - margin.left - margin.right,\n\t\theight = 500 - margin.top - margin.bottom,\n\t\tx = d3.scale.ordinal().rangeRoundBands([0, width], 0.1),\n\t\ty = d3.scale.linear().range([height, 0]),\n\t\txAxis = d3.svg.axis().scale(x).orient('bottom'),\n\t\tyAxis = d3.svg.axis().scale(y).orient('left'),\n\t\tsvg = d3.select('#around .graph').append('svg')\n\t\t\t.attr('class', 'js-graph')\n\t\t\t.attr('width', width + margin.left + margin.right)\n\t\t\t.attr('height', height + margin.top + margin.bottom)\n\t\t\t.append('g')\n\t\t\t.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'),\n\t\tdefs = \td3.select('#around .graph svg g').append('defs')\n\t\t\t.append('linearGradient')\n\t\t\t.attr('id', 'grad')\n\t\t\t.attr('x1', '0%')\n\t\t\t.attr('y1', '0%')\n\t\t\t.attr('x2', '0%')\n\t\t\t.attr('y2', '100%')\n\t\t\t.append('stop')\n\t\t\t.attr('offset', '0%')\n\t\t\t.attr('style', 'stop-color:#ff7800;stop-opacity:1'),\n\t\tstop2 = d3.select('#around .graph #grad').append('stop')\n\t\t\t.attr('offset', '100%')\n\t\t\t.attr('style', 'stop-color:#ff9a41;stop-opacity:1'),\n\n\t\trevealStats = function(processedData) {\n\t\t\tsvg.selectAll('.bar')\n\t\t\t\t.data(processedData)\n\t\t\t\t.enter()\n\t\t\t\t.append('rect')\n\t\t\t\t.attr('class', 'bar')\n\t\t\t\t.attr('x', function(d) {\n\t\t\t\t\treturn x(d.week);\n\t\t\t\t})\n\t\t\t\t.attr('width', x.rangeBand() - 7)\n\t\t\t\t.attr('y', function(d) {\n\t\t\t\t\treturn height - 0.5;\n\t\t\t\t})\n\t\t\t\t.attr('height', 0)\n\t\t\t\t.attr('fill', '#FF7800')\n\t\t\t\t.transition().delay(function(d, i) {\n\t\t\t\t\treturn i * 50;\n\t\t\t\t}).duration(1500)\n\t\t\t\t.ease('bounce')\n\t\t\t\t.attr('y', function(d) {\n\t\t\t\t\treturn y(d.users);\n\t\t\t\t})\n\t\t\t\t.attr('height', function(d) {\n\t\t\t\t\treturn height - y(d.users) - 0.5;\n\t\t\t\t});\n\t\t};\n\n\t// execution according to locale\n\tif (customLocales.indexOf(locale) === -1) {\n\t\t// do for all other locales\n\t\tlocale = 'XX'; // worldwide statistic\n\t\t$additional.hide();\n\t\t$local.hide();\n\t} else {\n\t\t// do for custom locales\n\t\tlocale = locale.toUpperCase();\n\t\t$global.hide();\n\t}\n\n\tvar xhr = new XMLHttpRequest();\n\txhr.open('GET', url);\n\txhr.setRequestHeader('X-Requested-With', 'XmlHttpRequest');\n\txhr.onreadystatechange = function() {\n\t\tif (xhr.readyState !== 4) {\n\t\t\treturn;\n\t\t}\n\t\tif (xhr.status === 200) {\n\t\t\trenderGraph(JSON.parse(xhr.responseText));\n\t\t} else {\n\t\t\tconsole.log('HTTP error', xhr.status, xhr.statusText);\n\t\t}\n\t};\n\txhr.send();\n\n\t// get data for graph and render it\n\tfunction renderGraph(data) {\n\t\t// create array from data object for current country\n\t\tvar processedData = [],\n\t\t\t$graph = $('.js-graph');\n\t\tfor (var name in data) {\n\t\t\tprocessedData.push({\n\t\t\t\tweek: name,\n\t\t\t\tusers: data[name][locale].users\n\t\t\t});\n\t\t}\n\n\t\t// leave only last 30 items in array\n\t\tif (processedData.length > 30) {\n\t\t\tprocessedData = processedData.splice(processedData.length - 30);\n\t\t}\n\n\t\t// add data to sentences above graph with proper thousand milestones\n\t\t$users.html(thMil(processedData[processedData.length - 1].users));\n\n\t\t// Add graph\n\t\tx.domain(processedData.map(function(d) {\n\t\t\treturn d.week;\n\t\t}));\n\t\t// y.domain([0, d3.max(processedData, function(d) { return d.users; })]);\n\t\ty.domain([0, d3.max(processedData, function(d) {\n\t\t\treturn d.users / 6 + d.users;\n\t\t})]);\n\n\t\tsvg.append('g')\n\t\t\t.attr('class', 'x axis')\n\t\t// .attr('transform', 'translate(0,' + height + ')')\n\t\t\t.attr('transform', 'translate(-3, 420)')\n\t\t//\t\t\t.attr('transform', 'translate(-3, 460)')\n\t\t\t.call(xAxis);\n\n\t\tsvg.append('g')\n\t\t\t.attr('class', 'y axis')\n\t\t\t.attr('transform', 'translate(0, 0)')\n\t\t\t.call(yAxis);\n\n\t\t// add circles to x axis\n\t\td3.select('.x.axis')\n\t\t\t.selectAll('g.tick')\n\t\t\t.insert('circle', ':first-child')\n\t\t\t.attr('r', 5).style('fill', '#94A2AA');\n\n\t\td3.selectAll('.x.axis g.tick text')\n\t\t\t.attr('y', 25);\n\n\t\t// Scroll to graph\n\t\t$window.on('scroll', function() {\n\t\t\tif ($around.offset().top + $around.height() - 200 < window.pageYOffset + window.innerHeight) {\n\t\t\t\trevealStats(processedData);\n\t\t\t}\n\t\t});\n\n\t\t// Responsive graph\n\t\t//\t\t$window.on('resize', function () {\n\t\t//\t\t\t$graph.attr('width', mediaQueryLogic().graphWidth);\n\t\t//\t\t});\n\t\t//\t\t$graph.attr('width', mediaQueryLogic().graphWidth);\n\n\t\t// on page load in viewport\n\t\tif ($around.offset().top + $around.height() - 200 < window.pageYOffset + window.innerHeight) {\n\t\t\trevealStats(processedData);\n\t\t}\n\t}\n})();\n\nvar sliderMyCarousel = tns({\n\tcontainer: '.slider-win10-av-reviews',\n\tcontrolsContainer: '.slider-win10-av-reviews-controls',\n\tcontrolsPosition: 'bottom',\n\tcontrols: false,\n\tnavPosition: 'bottom',\n\tmouseDrag: true,\n\tspeed: 400,\n\tfixedWidth: 304,\n\tpreventScrollOnTouch: 'auto',\n\tresponsive: {\n\t\t576: {\n\t\t\tcenter: true\n\t\t},\n\t\t768: {\n\t\t\titems: 2,\n\t\t\tslideBy: 2,\n\t\t\tcontrols: true,\n\t\t\tcenter: false\n\t\t},\n\t\t1280: {\n\t\t\tfixedWidth: 408\n\t\t},\n\t\t1366: {\n\t\t\tfixedWidth: 436\n\t\t},\n\t\t1600: {\n\t\t\tfixedWidth: 464\n\t\t}\n\t}\n});\n\n\n/* ----------------------------------\n\tGLOWEB-5636\n---------------------------------- */\nif ($(\".slider-win10-av-reviews-gloweb-5636-variant-b\").length > 0) {\n\n\tvar sliderMyCarouselVariantB = tns({\n\t\tcontainer: '.slider-win10-av-reviews-gloweb-5636-variant-b',\n\t\tcontrolsContainer: '.slider-win10-av-reviews-gloweb-5636-variant-b-controls',\n\t\tcontrolsPosition: 'bottom',\n\t\tcontrols: false,\n\t\tnavPosition: 'bottom',\n\t\tmouseDrag: true,\n\t\tspeed: 400,\n\t\tfixedWidth: 304,\n\t\tpreventScrollOnTouch: 'auto',\n\t\tresponsive: {\n\t\t\t576: {\n\t\t\t\tcenter: true\n\t\t\t},\n\t\t\t768: {\n\t\t\t\titems: 2,\n\t\t\t\tslideBy: 2,\n\t\t\t\tcontrols: true,\n\t\t\t\tcenter: false\n\t\t\t},\n\t\t\t1280: {\n\t\t\t\tfixedWidth: 408\n\t\t\t},\n\t\t\t1366: {\n\t\t\t\tfixedWidth: 436\n\t\t\t},\n\t\t\t1600: {\n\t\t\t\tfixedWidth: 464\n\t\t\t}\n\t\t}\n\t});\n}\n/* ----------------------------------\n\t/GLOWEB-5636\n---------------------------------- */\n"]}