How to use closeLocations method in stryker-parent

Best JavaScript code snippet using stryker-parent

main.js

Source:main.js Github

copy

Full Screen

1var map;2var st = 0, ap = 0, we = 0;3var locations = [], rent = [], traffic =[], cook = [], crimes = [], crimesassault = [];4var labels =[];5var siteA = {}6var siteB = {}7/*variables que contendran la informacion en "infowindow" de google maps*/8var contentStringSiteA;9var contentStringSiteB;1011function initMap() {12 var locationComputerEngineering = {lat: 41.8708, lng: -87.6505};13 map = new google.maps.Map(document.getElementById('map'), {14 center: locationComputerEngineering,15 zoom: 1216 });1718 var marker = new google.maps.Marker({19 position: locationComputerEngineering,20 icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',21 map:map22 });2324 var markerA = new google.maps.Marker({25 position: siteA,26 icon: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png',27 map:map28 });29 var markerB = new google.maps.Marker({30 position: siteB,31 icon: 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',32 map:map33 });34 var contentString = '<div id="content">'+35 '<div id="siteNotice">'+36 '</div>'+37 '<h1 id="firstHeading" class="firstHeading">UIC</h1>'+38 '<div id="bodyContent">'+39 '<p><b>"The largest university in one of the world’s most vibrant cities</b>.'+40 'The University of Illinois at Chicago is an acclaimed research institution ' +41 ' with 15 colleges dedicated to the discovery and distribution of knowledge."'+42 '</div>'+43 '</div>';4445 var infowindow = new google.maps.InfoWindow({46 content: contentString,47 maxWidth: 20048 });4950 marker.addListener('click', function() {51 infowindow.open(map, marker);52});5354 var infowindowSiteA = new google.maps.InfoWindow({55 content: contentStringSiteA,56 maxWidth: 30057 });5859 markerA.addListener('click', function() {60 infowindowSiteA.open(map, markerA);61});6263 var infowindowSiteB = new google.maps.InfoWindow({64 content: contentStringSiteB,65 maxWidth: 30066 });6768 markerB.addListener('click', function() {69 infowindowSiteB.open(map, markerB);70});717273 /*74 var markers = locations.map(function(location, i) {75 return new google.maps.Marker({76 position: location,77 label: {text: labels[i % labels.length], color: "black"}78 });79 });8081 // Add a marker clusterer to manage the markers.82 var markerCluster = new MarkerClusterer(map, markers,83 {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});84 */85}8687function distance(x2, x1, y2, y1 ) {88 return Math.sqrt(Math.pow((x2-x1), 2)+Math.pow((y2-y1), 2));89}9091function defaultRecommendation(allInformation, closeLocations){92 var siteinfor = [new Array(),new Array()], currentTotalRent = 0, currentTotalCrimes = 0;93 /* area Community area ,total rents, ilegal weapons, assault*/94 var area1 = [closeLocations[0],0,0,0], area2=[closeLocations[0], 0, 0,0];95 var lat = 41.8708 , lon = -87.6505;9697 /* filter Community area */98 for(i in closeLocations){99 currentTotalRent = allInformation[closeLocations[i]]['rents'].length;100 currentTotalCrimesW = allInformation[closeLocations[i]]['crimes']['weaponsviolation'].length;101 currentTotalCrimesA = allInformation[closeLocations[i]]['crimes']['crimesassault'].length;102/*103 console.log(" Total rents to " + closeLocations[i] + " = "+allInformation[closeLocations[i]]['rents'].length);104 console.log(" Total crimes ts to " + closeLocations[i] + " = " +(105 allInformation[closeLocations[i]]['crimes']['weaponsviolation'].length+allInformation[closeLocations[i]]['crimes']['crimesassault'].length));106 console.log(" Traffic to " + closeLocations[i] + " = " +allInformation[closeLocations[i]]['traffic'][0]);107*/108 /*Initial values*/109 if(area1[1] == 0 && area2[1] == 0){110 area1[1] = currentTotalRent111 area2[1] = area1[1];112 area1[2] = currentTotalCrimesW;113 area2[2] = area1[2];114 area1[3] = currentTotalCrimesA;115 area2[3] = area1[3];116 }117 /* Update select area */118 if((area1[2]+area1[3]) > (currentTotalCrimesW+currentTotalCrimesA)){119 area1[0] = closeLocations[i];120 area1[1] = currentTotalRent;121 area1[2] = currentTotalCrimesW;122 area1[3] = currentTotalCrimesA;123 }124 /*It is more important the variable assault that weapons because the crime of weapos is considered when125 it is carried without documents, does not necessarily indicate danger*/126 else if( (area1[2]+area1[3]) == (currentTotalCrimesW+currentTotalCrimesA) ){127 if(area1[3] > currentTotalCrimesA){128 area1[0] = closeLocations[i];129 area1[1] = currentTotalRent;130 area1[2] = currentTotalCrimesW;131 area1[3] = currentTotalCrimesA;132 }133 }134 if(currentTotalRent > 1)135 area2 = area1.slice(0);136137 }138139 console.log("Area mas cercana recomendad " + area1[0]);140 console.log("Rents " + area1[1]);141 console.log("Crimes" + (area1[2]+area1[3]));142143 /*Filter the win sites*/144 var moreClose = [distance(allInformation[area1[0]]['rents'][0][3] , lat, allInformation[area1[0]]['rents'][0][4], lon ),145 distance(allInformation[area1[0]]['rents'][1][3] , lat, allInformation[area1[0]]['rents'][1][4], lon )];146147 /*Default value for siteB*/148 siteinfor[1] = allInformation[area1[0]]['rents'][1].slice(0);149 for( i in allInformation[area1[0]]['rents']){150 if( moreClose[0] > distance(allInformation[area1[0]]['rents'][i][3] , lat, allInformation[area1[0]]['rents'][i][4], lon )){151 moreClose[0] = distance( allInformation[area1[0]]['rents'][i][3] , lat, allInformation[area1[0]]['rents'][i][4], lon );152 siteinfor[0] = allInformation[area1[0]]['rents'][i].slice(0);153 }154 else if( moreClose[1] > distance(allInformation[area1[0]]['rents'][i][3] , lat, allInformation[area1[0]]['rents'][i][4], lon )){155 moreClose[1] = distance( allInformation[area1[0]]['rents'][i][3] , lat, allInformation[area1[0]]['rents'][i][4], lon );156 siteinfor[1] = allInformation[area1[0]]['rents'][i].slice(0);157 }158 }159160 //siteA = new google.maps.LatLng(parseFloat(siteAinfor[3]), parseFloat(siteAinfor[4]));161 siteA = {lat: parseFloat(siteinfor[0][3]), lng: parseFloat(siteinfor[0][4])};162 siteB = {lat: parseFloat(siteinfor[1][3]), lng: parseFloat(siteinfor[1][4])};163 console.log(siteinfor);164 /*Build InfoWindows*/165 contentStringSiteA = '<div id="contentSiteA">'+166 '<div id="siteNoticeA">'+167 '</div>'+168 '<h2 id="firstHeading" class="firstHeading">Recommended site 1!!!</h2>'+169 '<div id="bodyContent">'+170 '<p>"This apartment has been chosen because it is the best option among all'+171 'the offers in chicaco, according to our algorithm of recommendation,which takes into account various types of crimes that occur throughout the city,'+172 'and the distance of this with your university UIC, To be able to select the safest,affordable, comfortable and dry place to live while you study.'+173 '<h3 >Basic information of this site:</h3>'+174 '<h5 id="firstHeading" class="firstHeading">Crimes in 2017 in the Community area</h5>'+175 (area1[2]+area1[3]) +176 '<h5 id="firstHeading" class="firstHeading">Property:</h5>'+177 siteinfor[0][0]+178 '<h5 id="firstHeading" class="firstHeading">Address:</h5>'+179 siteinfor[0][1]+180 '<h5 id="firstHeading" class="firstHeading">Phone:</h5>'+181 siteinfor[0][2]+182 '</div>'+183 '</div>';184 contentStringSiteB = '<div id="content">'+185 '<div id="siteNotice">'+186 '</div>'+187 '<h2 id="firstHeading" class="firstHeading">Recommended site 2!!!</h2>'+188 '<div id="bodyContent">'+189 '<p>"This apartment has been chosen because it is the best option among all'+190 'the offers in chicaco, according to our algorithm of recommendation,which takes into account various types of crimes that occur throughout the city,'+191 'and the distance of this with your university UIC, To be able to select the safest,affordable, comfortable and dry place to live while you study.'+192 '<h3 >Basic information of this site:</h3>'+193 '<h5 id="firstHeading" class="firstHeading">Crimes in 2017 in the Community area:</h5>'+194 (area1[2]+area1[3]) +195 '<h5 id="firstHeading" class="firstHeading">Property:</h5>'+196 siteinfor[1][0]+197 '<h5 id="firstHeading" class="firstHeading">Address:</h5>'+198 siteinfor[1][1]+199 '<h5 id="firstHeading" class="firstHeading">Phone:</h5>'+200 siteinfor[1][2]+201 '</div>'+202 '</div>';203204 initMap(siteA, siteB);205}206207function doMagic(){208 /*Restart values */209 document.getElementById('dashboard').innerHTML = "";210 st = 0, ap = 0, we = 0;211 var allInformation = {};212 var closeLocations = [28,32,33,8,24,27,31,29,30,23];213 contentStringSiteA;214 contentStringSiteB;215 /*Solo se tendran en cuenta las "Community Areas" donde hayan lugares en arriendo216 Make links217 */218 for( i in rent){219 if (!(rent[i][0] in allInformation))220 allInformation[rent[i][0]] = new Object({'rents': new Array(),221 'crimes': new Object({222 'weaponsviolation': new Array(),223 'crimesassault': new Array()}),224 'traffic': new Array()});225 allInformation[rent[i][0]]['rents'].push([rent[i][1], rent[i][2], rent[i][3], rent[i][4], rent[i][5]]);226 }227228 for( i in crimes){229 if ((crimes[i][0] in allInformation))230 allInformation[crimes[i][0]]['crimes']['weaponsviolation'].push([crimes[i][1], crimes[i][2], crimes[i][3], crimes[i][4], crimes[i][5]]);231 }232233 for( i in crimesassault){234 if ((crimesassault[i][0] in allInformation))235 allInformation[crimesassault[i][0]]['crimes']['crimesassault'].push([crimesassault[i][1], crimesassault[i][2], crimesassault[i][3], crimesassault[i][4], crimesassault[i][5]]);236 }237238 for( i in traffic){239 if ((traffic[i][0] in allInformation))240 allInformation[traffic[i][0]]['traffic'].push([traffic[i][1]]);241 }242243 /*----Finish links----*/244 /* Estimate recommended places */245 defaultRecommendation(allInformation, closeLocations);246 makeD3Graphs();247248249}250251function makeD3Graphs(){252 for( elements in crimes){253 if(crimes[elements][3] == "STREET")254 st += 1;255 else{256 ap += 1;257 }258 }259260 we = crimes.length;261 //initMap(locations, labels);262 chartsD3(st, ap, we);263}264265/******************** D3 taken from https://bl.ocks.org/mbostock ************************************/266function chartsD3(st, ap, we){267 function dashboard(id, fData){268 var barColor = 'steelblue';269 function segColor(c){ return {Street:"#807dba", Apartment:"#e08214",Weapons:"#41ab5d"}[c]; }270271 // compute total for each state.272 fData.forEach(function(d){d.total=d.freq.Street+d.freq.Apartment+d.freq.Weapons;});273274 // function to handle histogram.275 function histoGram(fD){276 var hG={}, hGDim = {t: 60, r: 0, b: 30, l: 0};277 hGDim.w = 500 - hGDim.l - hGDim.r,278 hGDim.h = 300 - hGDim.t - hGDim.b;279280 //create svg for histogram.281 var hGsvg = d3.select(id).append("svg")282 .attr("width", hGDim.w + hGDim.l + hGDim.r)283 .attr("height", hGDim.h + hGDim.t + hGDim.b).append("g")284 .attr("transform", "translate(" + hGDim.l + "," + hGDim.t + ")");285286 // create function for x-axis mapping.287 var x = d3.scale.ordinal().rangeRoundBands([0, hGDim.w], 0.1)288 .domain(fD.map(function(d) { return d[0]; }));289290 // Add x-axis to the histogram svg.291 hGsvg.append("g").attr("class", "x axis")292 .attr("transform", "translate(0," + hGDim.h + ")")293 .call(d3.svg.axis().scale(x).orient("bottom"));294295 // Create function for y-axis map.296 var y = d3.scale.linear().range([hGDim.h, 0])297 .domain([0, d3.max(fD, function(d) { return d[1]; })]);298299 // Create bars for histogram to contain rectangles and freq labels.300 var bars = hGsvg.selectAll(".bar").data(fD).enter()301 .append("g").attr("class", "bar");302303 //create the rectangles.304 bars.append("rect")305 .attr("x", function(d) { return x(d[0]); })306 .attr("y", function(d) { return y(d[1]); })307 .attr("width", x.rangeBand())308 .attr("height", function(d) { return hGDim.h - y(d[1]); })309 .attr('fill',barColor)310 .on("mouseover",mouseover)// mouseover is defined below.311 .on("mouseout",mouseout);// mouseout is defined below.312313 //Create the frequency labels above the rectangles.314 bars.append("text").text(function(d){ return d3.format(",")(d[1])})315 .attr("x", function(d) { return x(d[0])+x.rangeBand()/2; })316 .attr("y", function(d) { return y(d[1])-5; })317 .attr("text-anchor", "Apartmentdle");318319 function mouseover(d){ // utility function to be called on mouseover.320 // filter for selected state.321 var st = fData.filter(function(s){ return s.State == d[0];})[0],322 nD = d3.keys(st.freq).map(function(s){ return {type:s, freq:st.freq[s]};});323324 // call update functions of pie-chart and legend.325 pC.update(nD);326 leg.update(nD);327 }328329 function mouseout(d){ // utility function to be called on mouseout.330 // reset the pie-chart and legend.331 pC.update(tF);332 leg.update(tF);333 }334335 // create function to update the bars. This will be used by pie-chart.336 hG.update = function(nD, color){337 // update the domain of the y-axis map to reflect change in frequencies.338 y.domain([0, d3.max(nD, function(d) { return d[1]; })]);339340 // Attach the new data to the bars.341 var bars = hGsvg.selectAll(".bar").data(nD);342343 // transition the height and color of rectangles.344 bars.select("rect").transition().duration(500)345 .attr("y", function(d) {return y(d[1]); })346 .attr("height", function(d) { return hGDim.h - y(d[1]); })347 .attr("fill", color);348349 // transition the frequency labels location and change value.350 bars.select("text").transition().duration(500)351 .text(function(d){ return d3.format(",")(d[1])})352 .attr("y", function(d) {return y(d[1])-5; });353 }354 return hG;355 }356357 // function to handle pieChart.358 function pieChart(pD){359 var pC ={}, pieDim ={w:250, h: 250};360 pieDim.r = Math.min(pieDim.w, pieDim.h) / 2;361362 // create svg for pie chart.363 var piesvg = d3.select(id).append("svg")364 .attr("width", pieDim.w).attr("height", pieDim.h).append("g")365 .attr("transform", "translate("+pieDim.w/2+","+pieDim.h/2+")");366367 // create function to draw the arcs of the pie slices.368 var arc = d3.svg.arc().outerRadius(pieDim.r - 10).innerRadius(0);369370 // create a function to compute the pie slice angles.371 var pie = d3.layout.pie().sort(null).value(function(d) { return d.freq; });372373 // Draw the pie slices.374 piesvg.selectAll("path").data(pie(pD)).enter().append("path").attr("d", arc)375 .each(function(d) { this._current = d; })376 .style("fill", function(d) { return segColor(d.data.type); })377 .on("mouseover",mouseover).on("mouseout",mouseout);378379 // create function to update pie-chart. This will be used by histogram.380 pC.update = function(nD){381 piesvg.selectAll("path").data(pie(nD)).transition().duration(500)382 .attrTween("d", arcTween);383 }384 // Utility function to be called on mouseover a pie slice.385 function mouseover(d){386 // call the update function of histogram with new data.387 hG.update(fData.map(function(v){388 return [v.State,v.freq[d.data.type]];}),segColor(d.data.type));389 }390 //Utility function to be called on mouseout a pie slice.391 function mouseout(d){392 // call the update function of histogram with all data.393 hG.update(fData.map(function(v){394 return [v.State,v.total];}), barColor);395 }396 // Animating the pie-slice requiring a custom function which specifies397 // how the intermediate paths should be drawn.398 function arcTween(a) {399 var i = d3.interpolate(this._current, a);400 this._current = i(0);401 return function(t) { return arc(i(t)); };402 }403 return pC;404 }405406 // function to handle legend.407 function legend(lD){408 var leg = {};409410 // create table for legend.411 var legend = d3.select(id).append("table").attr('class','legend');412413 // create one row per segment.414 var tr = legend.append("tbody").selectAll("tr").data(lD).enter().append("tr");415416 // create the first column for each segment.417 tr.append("td").append("svg").attr("width", '16').attr("height", '16').append("rect")418 .attr("width", '16').attr("height", '16')419 .attr("fill",function(d){ return segColor(d.type); });420421 // create the second column for each segment.422 tr.append("td").text(function(d){ return d.type;});423424 // create the third column for each segment.425 tr.append("td").attr("class",'legendFreq')426 .text(function(d){ return d3.format(",")(d.freq);});427428 // create the fourth column for each segment.429 tr.append("td").attr("class",'legendPerc')430 .text(function(d){ return getLegend(d,lD);});431432 // Utility function to be used to update the legend.433 leg.update = function(nD){434 // update the data attached to the row elements.435 var l = legend.select("tbody").selectAll("tr").data(nD);436437 // update the frequencies.438 l.select(".legendFreq").text(function(d){ return d3.format(",")(d.freq);});439440 // update the percentage column.441 l.select(".legendPerc").text(function(d){ return getLegend(d,nD);});442 }443444 function getLegend(d,aD){ // Utility function to compute percentage.445 return d3.format("%")(d.freq/d3.sum(aD.map(function(v){ return v.freq; })));446 }447448 return leg;449 }450451 // calculate total frequency by segment for all state.452 var tF = ['Street','Apartment','Weapons'].map(function(d){453 return {type:d, freq: d3.sum(fData.map(function(t){ return t.freq[d];}))};454 });455456 // calculate total frequency by state for all segment.457 var sF = fData.map(function(d){return [d.State,d.total];});458459 var hG = histoGram(sF), // create the histogram.460 pC = pieChart(tF), // create the pie-chart.461 leg= legend(tF); // create the legend.462 }463 /***************************** END D3 ***************************************/464 var freqData=[465 {State:'2017',freq:{Street:st, Apartment:ap, Weapons:we}}];466 /*467 ,{State:'Febrero',freq:{Street:1101, Apartment:412, Weapons:674}}468 ,{State:'Marzo',freq:{Street:932, Apartment:2149, Weapons:418}}469 ,{State:'Abril',freq:{Street:832, Apartment:1152, Weapons:1862}}470 ];471 */472473 dashboard('#dashboard',freqData);474}475476/*477 Editorial by HTML5 UP478 html5up.net | @ajlkn479 Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)480*/481/* Code for HTML taken from html5up.net*/482(function($) {483484 skel.breakpoints({485 xlarge: '(max-width: 1680px)',486 large: '(max-width: 1280px)',487 medium: '(max-width: 980px)',488 small: '(max-width: 736px)',489 xsmall: '(max-width: 480px)',490 'xlarge-to-max': '(min-width: 1681px)',491 'small-to-xlarge': '(min-width: 481px) and (max-width: 1680px)'492 });493494 $(function() {495496 var $window = $(window),497 $head = $('head'),498 $body = $('body');499500 // Disable animations/transitions ...501502 // ... until the page has loaded.503 $body.addClass('is-loading');504505 $window.on('load', function() {506 setTimeout(function() {507 $body.removeClass('is-loading');508 }, 100);509 });510511 // ... when resizing.512 var resizeTimeout;513514 $window.on('resize', function() {515516 // Mark as resizing.517 $body.addClass('is-resizing');518519 // Unmark after delay.520 clearTimeout(resizeTimeout);521522 resizeTimeout = setTimeout(function() {523 $body.removeClass('is-resizing');524 }, 100);525526 });527528 // Fix: Placeholder polyfill.529 $('form').placeholder();530531 // Prioritize "important" elements on medium.532 skel.on('+medium -medium', function() {533 $.prioritize(534 '.important\\28 medium\\29',535 skel.breakpoint('medium').active536 );537 });538539 // Fixes.540541 // Object fit images.542 if (!skel.canUse('object-fit')543 || skel.vars.browser == 'safari')544 $('.image.object').each(function() {545546 var $this = $(this),547 $img = $this.children('img');548549 // Hide original image.550 $img.css('opacity', '0');551552 // Set background.553 $this554 .css('background-image', 'url("' + $img.attr('src') + '")')555 .css('background-size', $img.css('object-fit') ? $img.css('object-fit') : 'cover')556 .css('background-position', $img.css('object-position') ? $img.css('object-position') : 'center');557558 });559560 // Sidebar.561 var $sidebar = $('#sidebar'),562 $sidebar_inner = $sidebar.children('.inner');563564 // Inactive by default on <= large.565 skel566 .on('+large', function() {567 $sidebar.addClass('inactive');568 })569 .on('-large !large', function() {570 $sidebar.removeClass('inactive');571 });572573 // Hack: Workaround for Chrome/Android scrollbar position bug.574 if (skel.vars.os == 'android'575 && skel.vars.browser == 'chrome')576 $('<style>#sidebar .inner::-webkit-scrollbar { display: none; }</style>')577 .appendTo($head);578579 // Toggle.580 if (skel.vars.IEVersion > 9) {581582 $('<a href="#sidebar" class="toggle">Toggle</a>')583 .appendTo($sidebar)584 .on('click', function(event) {585586 // Prevent default.587 event.preventDefault();588 event.stopPropagation();589590 // Toggle.591 $sidebar.toggleClass('inactive');592593 });594595 }596597 // Events.598599 // Link clicks.600 $sidebar.on('click', 'a', function(event) {601602 // >large? Bail.603 if (!skel.breakpoint('large').active)604 return;605606 // Vars.607 var $a = $(this),608 href = $a.attr('href'),609 target = $a.attr('target');610611 // Prevent default.612 event.preventDefault();613 event.stopPropagation();614615 // Check URL.616 if (!href || href == '#' || href == '')617 return;618619 // Hide sidebar.620 $sidebar.addClass('inactive');621622 // Redirect to href.623 setTimeout(function() {624625 if (target == '_blank')626 window.open(href);627 else628 window.location.href = href;629630 }, 500);631632 });633634 // Prevent certain events inside the panel from bubbling.635 $sidebar.on('click touchend touchstart touchmove', function(event) {636637 // >large? Bail.638 if (!skel.breakpoint('large').active)639 return;640641 // Prevent propagation.642 event.stopPropagation();643644 });645646 // Hide panel on body click/tap.647 $body.on('click touchend', function(event) {648649 // >large? Bail.650 if (!skel.breakpoint('large').active)651 return;652653 // Deactivate.654 $sidebar.addClass('inactive');655656 });657658 // Scroll lock.659 // Note: If you do anything to change the height of the sidebar's content, be sure to660 // trigger 'resize.sidebar-lock' on $window so stuff doesn't get out of sync.661662 $window.on('load.sidebar-lock', function() {663664 var sh, wh, st;665666 // Reset scroll position to 0 if it's 1.667 if ($window.scrollTop() == 1)668 $window.scrollTop(0);669670 $window671 .on('scroll.sidebar-lock', function() {672673 var x, y;674675 // IE<10? Bail.676 if (skel.vars.IEVersion < 10)677 return;678679 // <=large? Bail.680 if (skel.breakpoint('large').active) {681682 $sidebar_inner683 .data('locked', 0)684 .css('position', '')685 .css('top', '');686687 return;688689 }690691 // Calculate positions.692 x = Math.max(sh - wh, 0);693 y = Math.max(0, $window.scrollTop() - x);694695 // Lock/unlock.696 if ($sidebar_inner.data('locked') == 1) {697698 if (y <= 0)699 $sidebar_inner700 .data('locked', 0)701 .css('position', '')702 .css('top', '');703 else704 $sidebar_inner705 .css('top', -1 * x);706707 }708 else {709710 if (y > 0)711 $sidebar_inner712 .data('locked', 1)713 .css('position', 'fixed')714 .css('top', -1 * x);715716 }717718 })719 .on('resize.sidebar-lock', function() {720721 // Calculate heights.722 wh = $window.height();723 sh = $sidebar_inner.outerHeight() + 30;724725 // Trigger scroll.726 $window.trigger('scroll.sidebar-lock');727728 })729 .trigger('resize.sidebar-lock');730731 });732733 // Menu.734 var $menu = $('#menu'),735 $menu_openers = $menu.children('ul').find('.opener');736737 // Openers.738 $menu_openers.each(function() {739740 var $this = $(this);741742 $this.on('click', function(event) {743744 // Prevent default.745 event.preventDefault();746747 // Toggle.748 $menu_openers.not($this).removeClass('active');749 $this.toggleClass('active');750751 // Trigger resize (sidebar lock).752 $window.triggerHandler('resize.sidebar-lock');753754 });755756 });757758 }); ...

Full Screen

Full Screen

Tracker.js

Source:Tracker.js Github

copy

Full Screen

1import React, { Component } from "react";2import { Link } from "react-router-dom";3import { Container, Row, Alert } from 'react-bootstrap';4import GoogleMapReact from 'google-map-react';5import firebase from "../firebase";6import Loader from "react-loader";7import './Main.css';8import { geolocated } from "react-geolocated";9import { GeoFirestore, } from 'geofirestore';10import Marker from './Marker';11const AnyReactComponent = ({ text }) => <div>{text}</div>;12const firestore = firebase.firestore();13const geoFirestore = new GeoFirestore(firestore);14class Tracker extends Component {15 constructor(props) {16 super(props);17 this.geoRef = firebase.firestore().collection("gcovidcollection");18 this.unsubscribe = null;19 this.state = {20 closeLocations: [],21 center: {}22 };23 }24 onCollectionUpdate = querySnapshot => {25 const closeLocations = [];26 querySnapshot.forEach(doc => {27 const { locales } = doc.data();28 closeLocations.push({29 key: doc.id,30 locales: doc.data().d,31 latestSymptom: doc.data().d.symptom.slice(-1).pop()32 });33 this.setState({34 loaded: true35 });36 });37 this.setState({38 closeLocations39 });40 this.setState({41 newCenter: {42 lat: this.props.coords.latitude,43 lng: this.props.coords.longitude44 }45 });46 };47 getMeTheColor(symptoms) {48 let numberOfYes = [symptoms.fever, symptoms.headAche, symptoms.diarrhea, symptoms.dryCough, symptoms.breathDiff].filter(Boolean).length49 if (numberOfYes == 5) { return "red" }50 else if (numberOfYes == 4) { return "orange" }51 else if (numberOfYes == 3 || numberOfYes == 2) { return "yellow" }52 else if (numberOfYes < 2) { return "green" }53 else { return "green" }54 }55 56 componentDidMount() {57 this.unsubscribe = this.geoRef.onSnapshot(this.onCollectionUpdate);58 }59 static defaultProps = {60 center: {61 lat: 60.95,62 lng: 24.3363 },64 zoom: 1165 };66 onChange = e => {67 const state = this.state;68 state[e.target.name] = e.target.value;69 this.setState(state);70 };71 render() {72 const { closeLocations } = this.state;73 return (74 <Container>75 <Container>76 <Alert variant="warning">77 <Container>78 <Alert.Heading>Hey,</Alert.Heading>79 <p>80 In total <strong>{closeLocations.length} </strong> people have reported their symptoms.81 Have you marked yourself? <a href="/">Update Symptoms</a>82 </p>83 <hr />84 <p className="mb-0">85 Here you can browse the symptoms reported in your locality. You can hover on the markers to know the symptoms.86 87 </p>88 <Row>89 <ul class="legend">90 <li ><span class="superawesome"></span> &lt; 2 symptoms</li>91 <li ><span class="kindaawesome"></span> 2 or 3 symptoms</li>92 <li ><span class="notawesome"></span> 3 or 4 symptoms</li>93 <li ><span class="not"></span>All symptoms</li>94 </ul>95 </Row>96 </Container>97 </Alert>98 <Loader loaded={this.state.loaded}>99 <div style={{ height: '100vh', width: '100%' }}>100 {closeLocations.length && <GoogleMapReact101 bootstrapURLKeys={{ key: "<Map Api Key. Restrict with HTTP refer>" }}102 defaultCenter={this.props.center}103 center={this.state.newCenter}104 defaultZoom={this.props.zoom}>105 {closeLocations.map((each) => (106 <Marker107 lat={each.locales.latitude}108 lng={each.locales.longitude}109 key={each.key}110 color={this.getMeTheColor(each.latestSymptom)}111 name={(each.latestSymptom.createdTs.toDate()+ each.key + (each.latestSymptom.fever ? "Fever: yes " : "Fever: No ")112 + (each.latestSymptom.headAche ? "HeadAche:yes " : "HeadAche:No ")113 + (each.latestSymptom.diarrhea ? "Diahhrea:yes " : "Diahhrea:No ")114 + (each.latestSymptom.dryCough ? "DryCough:yes " : "DryCough:No ")115 + (each.latestSymptom.breathDiff ? "Breathing Difficulty :yes " : "Breathing Difficulty:No ")116 )}117 />118 )119 )120 }121 </GoogleMapReact>}122 </div>123 </Loader>124 </Container>125 </Container>126 );127 }128}...

Full Screen

Full Screen

nearby.js

Source:nearby.js Github

copy

Full Screen

1// Try running in the console below.2 3exports = function(payload) {4 let lat = payload.query.lat;5 let long = payload.query.long;6 let distance = Number(payload.query.distance);7 let milesToDegrees = x=>{8 return x/69;9 };10 if(isNaN(lat) || isNaN(long) || isNaN(distance))11 return {error:"Invalid Data"};12 const mongodb = context.services.get("mongodb-atlas");13 return new Promise((resolve, reject) => {14 mongodb.db('prod').collection('locations').find().toArray().then(docs=>{15 let closeLocations = [];16 docs.forEach((data)=>{17 //resolve(`${data.timeEnd} now is ${Date.now()}`);18 //resolve(milesToDegrees(distance));19 if(Math.abs(lat - data.location.lat) < milesToDegrees(distance) && 20 Math.abs(long - data.location.long) < milesToDegrees(distance) &&21 data.timeEnd >= Date.now()){22 closeLocations.push(data);23 }24 });25 resolve(closeLocations);26 });27 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const closeLocations = require('stryker-parent').closeLocations;2 {3 },4 {5 }6];7const result = closeLocations(locations, 0.001);8console.log(result);9const closeLocations = require('stryker-parent').closeLocations;10 {11 },12 {13 }14];15const result = closeLocations(locations, 0.001);16console.log(result);17const closeLocations = require('stryker-parent').closeLocations;18 {19 },20 {21 }22];23const result = closeLocations(locations, 0.001);24console.log(result);25const closeLocations = require('stryker-parent').closeLocations;26 {27 },28 {29 }30];31const result = closeLocations(locations, 0.001);32console.log(result);33const closeLocations = require('stryker-parent').closeLocations;34 {35 },36 {37 }38];39const result = closeLocations(locations, 0.001);40console.log(result);41const closeLocations = require('stryker-parent').closeLocations;42 {

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const locations = strykerParent.closeLocations(1, 2, 3, 4);3console.log(locations);4const strykerParent = require('stryker-parent');5const locations = strykerParent.closeLocations(1, 2, 3, 4);6console.log(locations);7const strykerParent = require('stryker-parent');8const locations = strykerParent.closeLocations(1, 2, 3, 4);9console.log(locations);10const strykerParent = require('stryker-parent');11const locations = strykerParent.closeLocations(1, 2, 3, 4);12console.log(locations);13const strykerParent = require('stryker-parent');14const locations = strykerParent.closeLocations(1, 2, 3, 4);15console.log(locations);16const strykerParent = require('stryker-parent');17const locations = strykerParent.closeLocations(1, 2, 3, 4);18console.log(locations);19const strykerParent = require('stryker-parent');20const locations = strykerParent.closeLocations(1, 2, 3, 4);21console.log(locations);22const strykerParent = require('stryker-parent');23const locations = strykerParent.closeLocations(1, 2, 3, 4);24console.log(locations);25const strykerParent = require('stryker-parent');26const locations = strykerParent.closeLocations(1, 2, 3, 4);27console.log(locations);

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.closeLocations(function(locations) {3});4var stryker = require('stryker-parent');5stryker.closeLocations(function(locations) {6});7var stryker = require('stryker-parent');8stryker.closeLocations(function(locations) {9});10var stryker = require('stryker-parent');11stryker.closeLocations(function(locations) {12});13var stryker = require('stryker-parent');14stryker.closeLocations(function(locations) {15});16var stryker = require('stryker-parent');17stryker.closeLocations(function(locations) {18});19var stryker = require('stryker-parent');20stryker.closeLocations(function(locations) {21});22var stryker = require('stryker-parent');23stryker.closeLocations(function(locations) {24});25var stryker = require('stryker-parent');26stryker.closeLocations(function(locations) {27});28var stryker = require('stryker-parent');29stryker.closeLocations(function(locations) {30});31var stryker = require('stryker-parent');32stryker.closeLocations(function(locations) {33});

Full Screen

Using AI Code Generation

copy

Full Screen

1var closeLocations = require('stryker-parent').closeLocations;2 { name: 'A', lat: 51.507351, long: -0.127758 },3 { name: 'B', lat: 51.507351, long: -0.127758 },4 { name: 'C', lat: 51.507351, long: -0.127758 },5 { name: 'D', lat: 51.507351, long: -0.127758 },6 { name: 'E', lat: 51.507351, long: -0.127758 }7];8var closeLocations = closeLocations(locations, 5);9console.log(closeLocations);10var closeLocations = closeLocations(locations, 10);11console.log(closeLocations);12var closeLocations = closeLocations(locations, 15);13console.log(closeLocations);14var closeLocations = closeLocations(locations, 20);15console.log(closeLocations);16var closeLocations = closeLocations(locations, 25);17console.log(closeLocations);18var closeLocations = closeLocations(locations, 30);19console.log(closeLocations);20var closeLocations = closeLocations(locations, 35);21console.log(closeLocations);22var closeLocations = closeLocations(locations, 40);23console.log(closeLocations);24var closeLocations = closeLocations(locations, 45);25console.log(closeLocations);26var closeLocations = closeLocations(locations, 50);27console.log(closeLocations);28var closeLocations = closeLocations(locations, 55);29console.log(closeLocations);

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const locations = strykerParent.closeLocations(10, 10, 5);3console.log(locations);4module.exports = {5 closeLocations: function (x, y, radius) {6 }7}8module.exports = {9 closeLocations: function (x, y, radius) {10 }11}12const strykerParent = require('/home/user/test/stryker-parent');13const locations = strykerParent.closeLocations(10, 10, 5);14console.log(locations);15module.exports = {16 closeLocations: function (x, y, radius) {17 }18}

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var childProcess = require('child_process');3var path = require('path');4var config = {5};6var child = childProcess.fork(path.join(__dirname, '..', 'node_modules', 'stryker', 'src', 'Stryker.js'), [JSON.stringify(config)], { cwd: __dirname });7child.send({ name: 'closeLocations' });8process.on('message', function (message) {9 if (message.name === 'closeLocations') {10 fileLocation.closeAll();11 testFileLocation.closeAll();12 }13});14module.exports = function(config) {15 config.set({16 afterTestRun: function (result) {17 if (result.status === 'timeout') {18 fileLocation.closeAll();19 testFileLocation.closeAll();20 }21 }22 });23};

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2 { lat: 52.3740300, lon: 4.8896900, name: 'Amsterdam' },3 { lat: 40.7127837, lon: -74.00594130000002, name: 'New York' },4 { lat: 51.5085300, lon: -0.0761320, name: 'London' },5 { lat: 48.8566140, lon: 2.3522219000000177, name: 'Paris' },6 { lat: 37.7749295, lon: -122.41941550000001, name: 'San Francisco' }7];8var result = strykerParent.closeLocations(locations, 4);9console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var closeLocations = require('stryker-parent').closeLocations;2var locations = closeLocations('test');3console.log(locations);4var closeLocations = require('./closeLocations');5module.exports = {6};7module.exports = function closeLocations(str) {8 return str + ' test';9};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful