diff --git a/assets/js/game.js b/assets/js/game.js index 7e9a211..6de0ba6 100644 --- a/assets/js/game.js +++ b/assets/js/game.js @@ -1 +1,289 @@ -'use strict';const _0x2f3f3d=_0x522a;(function(_0x28c52f,_0x241c32){const _0x6471a4=_0x522a,_0x10f607=_0x28c52f();while(!![]){try{const _0x49c61a=-parseInt(_0x6471a4(0x1af))/0x1+-parseInt(_0x6471a4(0x1db))/0x2*(parseInt(_0x6471a4(0x1b4))/0x3)+parseInt(_0x6471a4(0x1b7))/0x4+parseInt(_0x6471a4(0x198))/0x5+parseInt(_0x6471a4(0x1cc))/0x6+parseInt(_0x6471a4(0x19e))/0x7+parseInt(_0x6471a4(0x1a6))/0x8;if(_0x49c61a===_0x241c32)break;else _0x10f607['push'](_0x10f607['shift']());}catch(_0xcf1bba){_0x10f607['push'](_0x10f607['shift']());}}}(_0x4cf1,0x5c6ed));var map,resultmap,markers=[],guess_coordinates=[],true_location=[],accumulated_distance=0x0,current_name='',distance_from_guess=[],check_count=0x0,choiceLocation='HN';const boundingBoxVN={'HN':[105.77,20.96,105.88,21.05,0.003],'TPHCM':[106.62,10.71,106.75,10.83,0.005],'HP':[106.65,20.8,106.75,20.9,0.05],'ND':[0x6a,20.35,106.25,20.5,0.005],'DN':[108.17,0x10,108.25,16.1,0.005],'DL':[108.38,11.89,108.50,12.00,0.005],'DHLA':[106.35,10.85,106.45,10.95,0.005]};var minLat=boundingBoxVN[choiceLocation][0x1],maxLat=boundingBoxVN[choiceLocation][0x3],minLong=boundingBoxVN[choiceLocation][0x0],maxLong=boundingBoxVN[choiceLocation][0x2],delta=boundingBoxVN[choiceLocation][0x4];const accessToken='MLY|24113623194974280|5bf83fa202912f1cc3210b2cf968fb65';async function getRandomMapillaryImage(){const _0x4eb278=_0x522a,_0x1e5b33=Math[_0x4eb278(0x1cd)]()*(maxLat-minLat)+minLat,_0x211128=Math[_0x4eb278(0x1cd)]()*(maxLong-minLong)+minLong,_0x2454d8=[(_0x211128-delta)[_0x4eb278(0x18c)](0x4),(_0x1e5b33-delta)['toFixed'](0x4),(_0x211128+delta)[_0x4eb278(0x18c)](0x4),(_0x1e5b33+delta)[_0x4eb278(0x18c)](0x4)][_0x4eb278(0x1c0)](','),_0x514f4a=_0x4eb278(0x1de)+accessToken+'&fields=id,thumb_original_url,geometry,is_pano&limit=3&bbox='+_0x2454d8+'&is_pano=true';try{console['log'](_0x4eb278(0x1e8));const _0x36adbf=await fetch(_0x514f4a),_0x5e2489=await _0x36adbf[_0x4eb278(0x1c9)]();if(_0x5e2489['data']&&_0x5e2489['data']['length']>0x0){const _0x20dd30=_0x5e2489['data'][_0x4eb278(0x190)](_0x5bcfd5=>_0x5bcfd5[_0x4eb278(0x18a)]),_0x2e6a28=_0x20dd30[_0x4eb278(0x1ab)]>0x0?_0x20dd30[Math[_0x4eb278(0x186)](Math[_0x4eb278(0x1cd)]()*_0x20dd30[_0x4eb278(0x1ab)])]:_0x5e2489[_0x4eb278(0x1cf)][0x0];return console[_0x4eb278(0x1a1)](_0x4eb278(0x1ca)),{'lat':_0x2e6a28[_0x4eb278(0x189)][_0x4eb278(0x1b1)][0x1],'lng':_0x2e6a28[_0x4eb278(0x189)][_0x4eb278(0x1b1)][0x0],'url':_0x2e6a28['thumb_original_url'],'id':_0x2e6a28['id'],'isPano':_0x2e6a28[_0x4eb278(0x18a)]||![]};}else return console[_0x4eb278(0x1a1)](_0x4eb278(0x1c7)),getRandomMapillaryImage();}catch(_0x498c14){console['error']('Error\x20fetching\x20image:',_0x498c14),document[_0x4eb278(0x1b0)](_0x4eb278(0x1e1))[_0x4eb278(0x19d)]=_0x4eb278(0x1aa),setTimeout(()=>getRandomMapillaryImage(),0x7d0);}}function checkLibrariesLoaded(){return new Promise(_0x5b45ac=>{const _0x53b944=setInterval(()=>{window['L']&&window['PhotoSphereViewer']&&(clearInterval(_0x53b944),_0x5b45ac());},0x64);});}function showLoading(){const _0x5a4801=_0x522a;document['getElementById'](_0x5a4801(0x1e1))[_0x5a4801(0x19d)]=_0x5a4801(0x1c5);if(!document[_0x5a4801(0x1b0)]('loading-styles')){const _0x54e63f=document[_0x5a4801(0x1a9)](_0x5a4801(0x1e2));_0x54e63f['id']=_0x5a4801(0x1e7),_0x54e63f['textContent']=_0x5a4801(0x1cb),document['head'][_0x5a4801(0x199)](_0x54e63f);}}function hideLoading(){const _0x37fc0f=_0x522a,_0x336799=document['getElementById'](_0x37fc0f(0x1e1));_0x336799&&_0x336799[_0x37fc0f(0x19d)][_0x37fc0f(0x1b3)](_0x37fc0f(0x1c1))&&(_0x336799[_0x37fc0f(0x19d)]='');}function initialize(){const _0x5f0fbe=_0x522a;check_count=0x0,disableButton(_0x5f0fbe(0x1ba)),showLoading(),getRandomMapillaryImage()[_0x5f0fbe(0x1c6)](_0x322477=>{const _0x20a7c9=_0x5f0fbe;if(!_0x322477)return location[_0x20a7c9(0x1bb)]();true_location=[_0x322477[_0x20a7c9(0x1c8)],_0x322477['lng']],current_name=_0x20a7c9(0x19b),document['getElementById'](_0x20a7c9(0x1e1))[_0x20a7c9(0x19d)]='';try{if(window[_0x20a7c9(0x1dc)]&&window[_0x20a7c9(0x1dc)][_0x20a7c9(0x1df)]){hideLoading();const _0x106e35=new PhotoSphereViewer[(_0x20a7c9(0x1df))]({'container':document[_0x20a7c9(0x1b0)](_0x20a7c9(0x1e1)),'panorama':_0x322477['url'],'loadingImg':null,'defaultYaw':0x0,'defaultZoomLvl':-0x60,'navbar':[_0x20a7c9(0x1bc),_0x20a7c9(0x1a5)],'mousewheel':!![],'touchmoveTwoFingers':!![]});_0x106e35[_0x20a7c9(0x1c4)]('ready',()=>{const _0x2b61e9=_0x20a7c9;console['log'](_0x2b61e9(0x1e3));}),_0x106e35[_0x20a7c9(0x1c4)](_0x20a7c9(0x1ad),()=>{const _0x318013=_0x20a7c9;console[_0x318013(0x1a1)](_0x318013(0x1d0));}),_0x106e35['addEventListener']('panorama-error',_0x1c0c5c=>{const _0x61576b=_0x20a7c9;console['error'](_0x61576b(0x1ce),_0x1c0c5c),hideLoading(),document[_0x61576b(0x1b0)]('pano')[_0x61576b(0x19d)]=_0x61576b(0x19c)+_0x322477[_0x61576b(0x18b)]+'\x22\x20style=\x22width:100%;\x20height:100%;\x20object-fit:cover;\x20border-radius:10px;\x22\x20/>';});}else console[_0x20a7c9(0x1b6)](_0x20a7c9(0x1a3)),hideLoading(),document[_0x20a7c9(0x1b0)]('pano')[_0x20a7c9(0x19d)]='';}catch(_0x5772f5){console[_0x20a7c9(0x1d3)](_0x20a7c9(0x197),_0x5772f5),hideLoading(),document[_0x20a7c9(0x1b0)](_0x20a7c9(0x1e1))[_0x20a7c9(0x19d)]=_0x20a7c9(0x19c)+_0x322477['url']+_0x20a7c9(0x194);}map=L[_0x20a7c9(0x1a8)](_0x20a7c9(0x1a8))[_0x20a7c9(0x1b9)]([(minLat+maxLat)/0x2,(minLong+maxLong)/0x2],0xa),L[_0x20a7c9(0x1d5)](_0x20a7c9(0x182),{'maxZoom':0x13})[_0x20a7c9(0x19f)](map),map['on']('click',function(_0x40567a){const _0xc2a507=_0x20a7c9;deleteMarkers(),guess_coordinates=[_0x40567a['latlng']['lat'],_0x40567a[_0xc2a507(0x1e4)][_0xc2a507(0x1be)]];const _0x4c4f9b=L[_0xc2a507(0x1c2)](_0x40567a[_0xc2a507(0x1e4)])[_0xc2a507(0x19f)](map);markers[_0xc2a507(0x1d8)](_0x4c4f9b),check_count===0x0&&(enableButton(_0xc2a507(0x1ba)),check_count+=0x1);});})[_0x5f0fbe(0x183)](_0x59af69=>{const _0x49ad80=_0x5f0fbe;console[_0x49ad80(0x1d3)](_0x49ad80(0x1b5),_0x59af69),document[_0x49ad80(0x1b0)](_0x49ad80(0x1e1))[_0x49ad80(0x19d)]='\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20⚠️\x20Failed\x20to\x20load\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Retry\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20';});}function clearMarkers(){const _0x40290f=_0x522a;for(let _0x172f86=0x0;_0x172f860x1)_0xc2f51b=0x1;_0xc2f51b=Math[_0x3a989e(0x195)](_0xc2f51b),_0xc2f51b=_0xc2f51b*0xb4/Math['PI'],_0xc2f51b=_0xc2f51b*0x3c*1.1515;if(_0x1a420b=='K')_0xc2f51b=_0xc2f51b*1.609344;if(_0x1a420b=='N')_0xc2f51b=_0xc2f51b*0.8684;return _0xc2f51b=_0xc2f51b*1609.34,_0xc2f51b[_0x3a989e(0x18c)](0x1);}}function display_location(){const _0x4be998=_0x522a,_0x525f5a=document['getElementById'](_0x4be998(0x184));if(distance_from_guess>0x3e8)_0x525f5a[_0x4be998(0x19d)]=_0x4be998(0x1b8)+distance_from_guess+_0x4be998(0x1b2);else{if(distance_from_guess>0xc8)_0x525f5a[_0x4be998(0x19d)]='Good\x20job!\x20Your\x20distance\x20is\x20'+distance_from_guess+_0x4be998(0x1b2);else _0x525f5a[_0x4be998(0x19d)]=_0x4be998(0x193)+distance_from_guess+_0x4be998(0x1b2);}}function disableButton(_0x192b3e){const _0x1c0889=_0x522a;document[_0x1c0889(0x1b0)](_0x192b3e)['disabled']=!![];}function enableButton(_0x9b2383){const _0x366028=_0x522a;document[_0x366028(0x1b0)](_0x9b2383)[_0x366028(0x1ac)]=![];}function showResultModal(_0x6a4c37){const _0x2addc6=_0x522a,_0x282e45=document[_0x2addc6(0x1b0)]('resultModal'),_0x2868ea=document['getElementById'](_0x2addc6(0x1d9)),_0x545279=document[_0x2addc6(0x1b0)]('distance-guess');if(distance_from_guess>0x3e8)_0x545279['innerHTML']=(distance_from_guess/0x3e8)['toFixed'](0x2)+_0x2addc6(0x1e0);else _0x545279[_0x2addc6(0x19d)]=distance_from_guess+'\x20M';if(distance_from_guess>0x3e8)_0x2868ea['innerHTML']=_0x2addc6(0x1a4);else{if(distance_from_guess>0xc8)_0x2868ea[_0x2addc6(0x19d)]=_0x2addc6(0x1a7);else _0x2868ea[_0x2addc6(0x19d)]=_0x2addc6(0x19a);}_0x282e45['style'][_0x2addc6(0x18d)]=_0x2addc6(0x1da),createResultMap();}function createResultMap(){const _0x25d530=_0x522a,_0x30d8e9=document[_0x25d530(0x1b0)](_0x25d530(0x1a0));_0x30d8e9[_0x25d530(0x19d)]='';var _0x47b24a=L[_0x25d530(0x1a8)](_0x25d530(0x1a0))['setView'](true_location,0xc);L[_0x25d530(0x1d5)]('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{'maxZoom':0x13})[_0x25d530(0x19f)](_0x47b24a),setTimeout(()=>{_0x47b24a['invalidateSize']();},0x64);const _0x2ca010=L[_0x25d530(0x1c2)](true_location,{'icon':L[_0x25d530(0x1d6)]({'iconUrl':_0x25d530(0x18f),'iconSize':[0x20,0x20]})})['addTo'](_0x47b24a)[_0x25d530(0x1bf)](current_name),_0x1d678a=L[_0x25d530(0x1c2)](guess_coordinates,{'icon':L[_0x25d530(0x1d6)]({'iconUrl':_0x25d530(0x180),'iconSize':[0x20,0x20]})})[_0x25d530(0x19f)](_0x47b24a)['bindPopup']('Your\x20Guess'),_0x2f53f4=L[_0x25d530(0x196)]([true_location,guess_coordinates],{'color':_0x25d530(0x1a2),'dashArray':_0x25d530(0x188)})[_0x25d530(0x19f)](_0x47b24a),_0x28ce52=new L[(_0x25d530(0x1d1))]([_0x2ca010,_0x1d678a]);_0x47b24a[_0x25d530(0x192)](_0x28ce52[_0x25d530(0x1d4)]()[_0x25d530(0x191)](0.1));}function closeResultModal(){const _0x4b1b43=_0x522a;document[_0x4b1b43(0x1b0)]('resultModal')[_0x4b1b43(0x1e2)][_0x4b1b43(0x18d)]=_0x4b1b43(0x1e6);}function _0x4cf1(){const _0x1ef46e=['latlng','location','none','loading-styles','Fetching\x20panoramic\x20image...','https://maps.google.com/mapfiles/ms/icons/red-dot.png','href','https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png','catch','score','sin','floor','onload','5,\x2010','geometry','is_pano','url','toFixed','display','removeLayer','https://maps.google.com/mapfiles/ms/icons/green-dot.png','filter','pad','fitBounds','Excellent!\x20Your\x20distance\x20is\x20','\x22\x20style=\x22width:100%;\x20height:100%;\x20object-fit:cover;\x20border-radius:10px;\x22\x20/>','acos','polyline','Error\x20initializing\x20Photo\x20Sphere\x20Viewer:','103745uPEcCw','appendChild','Excellent!','VIET\x20NAM','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20⚠️\x20Error\x20loading\x20image\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Retrying...\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20','length','disabled','panorama-loaded','Modal','552735zVtQrk','getElementById','coordinates','m\x20away.','includes','110154MjTVEi','Error\x20in\x20initialize\x20function:','warn','467704UHjPyE','Hmm!\x20Your\x20distance\x20is\x20','setView','check','reload','zoom','get','lng','bindPopup','join','Loading\x20image...','marker','hide','addEventListener','\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Loading\x20image...\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20','then','No\x20images\x20found,\x20retrying...','lat','json','Image\x20fetched\x20successfully','\x0a\x20\x20\x20\x20\x20\x20@keyframes\x20spin\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x200%\x20{\x20transform:\x20rotate(0deg);\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20100%\x20{\x20transform:\x20rotate(360deg);\x20}\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20','3521016tqZJUl','random','Error\x20loading\x20panorama:','data','Panorama\x20image\x20loaded','featureGroup','resultModal','error','getBounds','tileLayer','icon','cos','push','resultText','block','18UgWapq','PhotoSphereViewer','donateModal','https://graph.mapillary.com/images?access_token=','Viewer','\x20KM','pano','style','Photo\x20Sphere\x20Viewer\x20loaded\x20successfully'];_0x4cf1=function(){return _0x1ef46e;};return _0x4cf1();}function nextRound(){closeResultModal(),location['reload']();}function goBack(){const _0x5444ac=_0x522a;window[_0x5444ac(0x1e5)][_0x5444ac(0x181)]='/';}function showDonateModal(){const _0x5821f2=_0x522a,_0x571872=document[_0x5821f2(0x1b0)](_0x5821f2(0x1dd));_0x571872['style']['display']=_0x5821f2(0x1da);}function closeDonate(){const _0x17e200=_0x522a,_0xb32e8c=document[_0x17e200(0x1b0)](_0x17e200(0x1dd));_0xb32e8c['style']['display']=_0x17e200(0x1e6);}window[_0x2f3f3d(0x187)]=function(){const _0x447466=_0x2f3f3d,_0x4e1bcd=new URLSearchParams(window[_0x447466(0x1e5)]['search']),_0x517d2e=_0x4e1bcd[_0x447466(0x1bd)]('location');_0x517d2e&&(choiceLocation=_0x517d2e),minLat=boundingBoxVN[choiceLocation][0x1],maxLat=boundingBoxVN[choiceLocation][0x3],minLong=boundingBoxVN[choiceLocation][0x0],maxLong=boundingBoxVN[choiceLocation][0x2],delta=boundingBoxVN[choiceLocation][0x4],checkLibrariesLoaded()[_0x447466(0x1c6)](()=>{initialize();});}; +'use strict'; + +var map; +var resultmap; +var markers = []; +var guess_coordinates = []; +var true_location = []; +var accumulated_distance = 0x0; +var current_name = ''; +var distance_from_guess = []; +var check_count = 0x0; +var choiceLocation = 'HN'; +const boundingBoxVN = { + 'HN': [105.77, 20.96, 105.88, 21.05, 0.003], + 'TPHCM': [106.62, 10.71, 106.75, 10.83, 0.005], + 'HP': [106.65, 20.8, 106.75, 20.9, 0.05], + 'ND': [0x6a, 20.35, 106.25, 20.5, 0.005], + 'DN': [108.17, 0x10, 108.25, 16.1, 0.005], + 'DL': [108.38, 11.89, 108.50, 12.00, 0.005], + 'DHLA': [106.35, 10.85, 106.45, 10.95, 0.005] +}; +var minLat = boundingBoxVN[choiceLocation][0x1]; +var maxLat = boundingBoxVN[choiceLocation][0x3]; +var minLong = boundingBoxVN[choiceLocation][0x0]; +var maxLong = boundingBoxVN[choiceLocation][0x2]; +var delta = boundingBoxVN[choiceLocation][0x4]; +async function getRandomMapillaryImage() { + const _0x1e5b33 = Math.random() * (maxLat - minLat) + minLat; + const _0x211128 = Math.random() * (maxLong - minLong) + minLong; + const _0x2454d8 = [(_0x211128 - delta).toFixed(0x4), (_0x1e5b33 - delta).toFixed(0x4), (_0x211128 + delta).toFixed(0x4), (_0x1e5b33 + delta).toFixed(0x4)].join(','); + const _0x514f4a = "https://graph.mapillary.com/images?access_token=MLY|24113623194974280|5bf83fa202912f1cc3210b2cf968fb65&fields=id,thumb_original_url,geometry,is_pano&limit=3&bbox=" + _0x2454d8 + '&is_pano=true'; + try { + console.log("Fetching panoramic image..."); + const _0x36adbf = await fetch(_0x514f4a); + const _0x5e2489 = await _0x36adbf.json(); + if (_0x5e2489.data && _0x5e2489.data.length > 0x0) { + const _0x20dd30 = _0x5e2489.data.filter(_0x5bcfd5 => _0x5bcfd5.is_pano); + const _0x2e6a28 = _0x20dd30.length > 0x0 ? _0x20dd30[Math.floor(Math.random() * _0x20dd30.length)] : _0x5e2489.data[0x0]; + console.log("Image fetched successfully"); + return { + 'lat': _0x2e6a28.geometry.coordinates[0x1], + 'lng': _0x2e6a28.geometry.coordinates[0x0], + 'url': _0x2e6a28.thumb_original_url, + 'id': _0x2e6a28.id, + 'isPano': _0x2e6a28.is_pano || false + }; + } else { + console.log("No images found, retrying..."); + return getRandomMapillaryImage(); + } + } catch (_0x498c14) { + console.error("Error fetching image:", _0x498c14); + document.getElementById("pano").innerHTML = "\n
\n
\n
⚠️ Error loading image
\n
Retrying...
\n
\n
\n "; + setTimeout(() => getRandomMapillaryImage(), 0x7d0); + } +} +function checkLibrariesLoaded() { + return new Promise(_0x5b45ac => { + const _0x53b944 = setInterval(() => { + if (window.L && window.PhotoSphereViewer) { + clearInterval(_0x53b944); + _0x5b45ac(); + } + }, 0x64); + }); +} +function showLoading() { + document.getElementById("pano").innerHTML = "\n
\n
\n
\n
Loading image...
\n
\n
\n "; + if (!document.getElementById('loading-styles')) { + const _0x54e63f = document.createElement("style"); + _0x54e63f.id = "loading-styles"; + _0x54e63f.textContent = "\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "; + document.head.appendChild(_0x54e63f); + } +} +function hideLoading() { + const _0x336799 = document.getElementById("pano"); + if (_0x336799 && _0x336799.innerHTML.includes("Loading image...")) { + _0x336799.innerHTML = ''; + } +} +function initialize() { + check_count = 0x0; + disableButton("check"); + showLoading(); + getRandomMapillaryImage().then(_0x322477 => { + if (!_0x322477) { + return location.reload(); + } + true_location = [_0x322477.lat, _0x322477.lng]; + current_name = "VIET NAM"; + document.getElementById("pano").innerHTML = ''; + try { + if (window.PhotoSphereViewer && window.PhotoSphereViewer.Viewer) { + hideLoading(); + const _0x106e35 = new PhotoSphereViewer.Viewer({ + 'container': document.getElementById("pano"), + 'panorama': _0x322477.url, + 'loadingImg': null, + 'defaultYaw': 0x0, + 'defaultZoomLvl': -0x60, + 'navbar': ["zoom", "fullscreen"], + 'mousewheel': true, + 'touchmoveTwoFingers': true + }); + _0x106e35.addEventListener('ready', () => { + console.log("Photo Sphere Viewer loaded successfully"); + }); + _0x106e35.addEventListener("panorama-loaded", () => { + console.log("Panorama image loaded"); + }); + _0x106e35.addEventListener('panorama-error', _0x1c0c5c => { + console.error("Error loading panorama:", _0x1c0c5c); + hideLoading(); + document.getElementById('pano').innerHTML = ""; + }); + } else { + console.warn("PhotoSphereViewer not available, using fallback image"); + hideLoading(); + document.getElementById('pano').innerHTML = ""; + } + } catch (_0x5772f5) { + console.error("Error initializing Photo Sphere Viewer:", _0x5772f5); + hideLoading(); + document.getElementById("pano").innerHTML = ""; + } + map = L.map("map").setView([(minLat + maxLat) / 0x2, (minLong + maxLong) / 0x2], 0xa); + L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { + 'maxZoom': 0x13 + }).addTo(map); + map.on('click', function (_0x40567a) { + deleteMarkers(); + guess_coordinates = [_0x40567a.latlng.lat, _0x40567a.latlng.lng]; + const _0x4c4f9b = L.marker(_0x40567a.latlng).addTo(map); + markers.push(_0x4c4f9b); + if (check_count === 0x0) { + enableButton("check"); + check_count += 0x1; + } + }); + })["catch"](_0x59af69 => { + console.error("Error in initialize function:", _0x59af69); + document.getElementById("pano").innerHTML = "\n
\n
\n
⚠️ Failed to load
\n \n
\n
\n "; + }); +} +function clearMarkers() { + for (let _0x172f86 = 0x0; _0x172f86 < markers.length; _0x172f86++) { + map.removeLayer(markers[_0x172f86]); + } + markers = []; +} +function deleteMarkers() { + clearMarkers(); +} +function continueGame() { + var _0x4e74e6 = new bootstrap.Modal(document.getElementById("resultModal")); + _0x4e74e6.hide(); + location.reload(); +} +function check() { + distance_from_guess = []; + var _0x1625f4 = distance(guess_coordinates[0x0], guess_coordinates[0x1], true_location[0x0], true_location[0x1], 'M'); + accumulated_distance += parseFloat(_0x1625f4); + distance_from_guess = _0x1625f4; + showResultModal(distance_from_guess); + disableButton("check"); +} +function distance(_0x17d630, _0x124646, _0x3a8477, _0x8b4b7c, _0x1a420b) { + if (_0x17d630 == _0x3a8477 && _0x124646 == _0x8b4b7c) { + return 0x0; + } else { + var _0x197d3c = Math.PI * _0x17d630 / 0xb4; + var _0x24a9f1 = Math.PI * _0x3a8477 / 0xb4; + var _0x50ac69 = _0x124646 - _0x8b4b7c; + var _0x9d3f4f = Math.PI * _0x50ac69 / 0xb4; + var _0xc2f51b = Math.sin(_0x197d3c) * Math.sin(_0x24a9f1) + Math.cos(_0x197d3c) * Math.cos(_0x24a9f1) * Math.cos(_0x9d3f4f); + if (_0xc2f51b > 0x1) { + _0xc2f51b = 0x1; + } + _0xc2f51b = Math.acos(_0xc2f51b); + _0xc2f51b = _0xc2f51b * 0xb4 / Math.PI; + _0xc2f51b = _0xc2f51b * 0x3c * 1.1515; + if (_0x1a420b == 'K') { + _0xc2f51b = _0xc2f51b * 1.609344; + } + if (_0x1a420b == 'N') { + _0xc2f51b = _0xc2f51b * 0.8684; + } + _0xc2f51b = _0xc2f51b * 1609.34; + return _0xc2f51b.toFixed(0x1); + } +} +function display_location() { + const _0x525f5a = document.getElementById("score"); + if (distance_from_guess > 0x3e8) { + _0x525f5a.innerHTML = "Hmm! Your distance is " + distance_from_guess + "m away."; + } else { + if (distance_from_guess > 0xc8) { + _0x525f5a.innerHTML = "Good job! Your distance is " + distance_from_guess + "m away."; + } else { + _0x525f5a.innerHTML = "Excellent! Your distance is " + distance_from_guess + "m away."; + } + } +} +function disableButton(_0x192b3e) { + document.getElementById(_0x192b3e).disabled = true; +} +function enableButton(_0x9b2383) { + document.getElementById(_0x9b2383).disabled = false; +} +function showResultModal(_0x6a4c37) { + const _0x282e45 = document.getElementById('resultModal'); + const _0x2868ea = document.getElementById("resultText"); + const _0x545279 = document.getElementById('distance-guess'); + if (distance_from_guess > 0x3e8) { + _0x545279.innerHTML = (distance_from_guess / 0x3e8).toFixed(0x2) + " KM"; + } else { + _0x545279.innerHTML = distance_from_guess + " M"; + } + if (distance_from_guess > 0x3e8) { + _0x2868ea.innerHTML = "Hmm! Nice try."; + } else { + if (distance_from_guess > 0xc8) { + _0x2868ea.innerHTML = "Good job!"; + } else { + _0x2868ea.innerHTML = "Excellent!"; + } + } + _0x282e45.style.display = "block"; + createResultMap(); +} +function createResultMap() { + const _0x30d8e9 = document.getElementById("result"); + _0x30d8e9.innerHTML = ''; + var _0x47b24a = L.map("result").setView(true_location, 0xc); + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + 'maxZoom': 0x13 + }).addTo(_0x47b24a); + setTimeout(() => { + _0x47b24a.invalidateSize(); + }, 0x64); + const _0x2ca010 = L.marker(true_location, { + 'icon': L.icon({ + 'iconUrl': "https://maps.google.com/mapfiles/ms/icons/green-dot.png", + 'iconSize': [0x20, 0x20] + }) + }).addTo(_0x47b24a).bindPopup(current_name); + const _0x1d678a = L.marker(guess_coordinates, { + 'icon': L.icon({ + 'iconUrl': "https://maps.google.com/mapfiles/ms/icons/red-dot.png", + 'iconSize': [0x20, 0x20] + }) + }).addTo(_0x47b24a).bindPopup("Your Guess"); + const _0x28ce52 = new L.featureGroup([_0x2ca010, _0x1d678a]); + _0x47b24a.fitBounds(_0x28ce52.getBounds().pad(0.1)); +} +function closeResultModal() { + document.getElementById('resultModal').style.display = "none"; +} +function nextRound() { + closeResultModal(); + location.reload(); +} +function goBack() { + window.location.href = '/'; +} +function showDonateModal() { + const _0x571872 = document.getElementById("donateModal"); + _0x571872.style.display = "block"; +} +function closeDonate() { + const _0xb32e8c = document.getElementById("donateModal"); + _0xb32e8c.style.display = "none"; +} +window.onload = function () { + const _0x4e1bcd = new URLSearchParams(window.location.search); + const _0x517d2e = _0x4e1bcd.get('location'); + if (_0x517d2e) { + choiceLocation = _0x517d2e; + } + minLat = boundingBoxVN[choiceLocation][0x1]; + maxLat = boundingBoxVN[choiceLocation][0x3]; + minLong = boundingBoxVN[choiceLocation][0x0]; + maxLong = boundingBoxVN[choiceLocation][0x2]; + delta = boundingBoxVN[choiceLocation][0x4]; + checkLibrariesLoaded().then(() => { + initialize(); + }); +};