/* * Copyright (c) 2021-2023 Virtual Park LLC. All Rights Reserved. * * No one other than us is allowed to copy, use, inspect, imitate, or even see this source code. */ function dataURItoBlob(dataURI){var byteString=atob(dataURI.split(',')[1]);var mimeString=dataURI.split(',')[0].split(':')[1].split(';')[0];var ab=new ArrayBuffer(byteString.length);var ia=new Uint8Array(ab);for(var i=0;i0 return!isNaN(str)&&!isNaN(parseFloat(str))&&parseFloat(str)>0} var app=angular.module('vpark',['ngSanitize']).controller('c-main',['$scope',function($scope){$scope.title="";}]);app.service('vService',function($http){var _self={_self:this,bearer:null,vParkUserConnected:null,loggedIn:false,state:null,scope:null,urls:{},migrate:window.migrate,init:function(scope){_self.scope=scope;_self.state=scope.state;},ajax:{call:function(url,method,auth,data,callback,error){if(auth&&!_self.loggedIn){alert("You are not logged in.");return;} $.ajax({url:url,contentType:"application/json",method:method,headers:auth?{Authorization:_self.bearer,Migrate:_self.migrate}:{Migrate:_self.migrate},data:data&&method!="GET"?JSON.stringify(data):null,success:function(data,textStatus,xhr){callback?callback(data):null;},error:function(data){$("#errorNotif").text(data.responseJSON.message).fadeIn(1000,()=>{setTimeout(()=>{$("#errorNotif").fadeOut(2000);},4000);});error?error(data):null;}});}},auth:{register:(email,password)=>{gtag('event','click',{'event_category':"Click",'event_label':"Register"});if(!_self.state.user.agree){alert("Please complete the form above.");return;} if(!_self.state.user.email||_self.state.user.email.length<6){alert("Please fill out the email & password fields before clicking the register button.");return;} if(!_self.state.user.password||_self.state.user.password.length<8){alert("Password must be at least 8 characters.");return;} $.post("/api/register",_self.state.user,(data)=>{if(data.status_code==200){fbq('track','CompleteRegistration',{value:0.1,currency:'USD'});gtag('event','sign_up',{"method":"vpark"});gtag('event','conversion',{'send_to':'AW-782748339/oqSNCPPl3oQYELOVn_UC'});alert("Please open your email to confirm your account within the next 60 mins. Check your mailbox quota/junk folder in the next 10 minutes if you can't find it. Quite often, users entered an invalid email address or use a corporate email with domain whitelisting.");mixpanel.track("Account",{"button":"register"});location.reload();}else{alert(data.message);}},"json");},login:function(userInfo,callback){_self.ajax.call("/api/login","POST",false,userInfo,(data)=>{_self.bearer="Bearer "+data.access_token;localStorage.setItem('access_token',_self.bearer);_self.loggedIn=true;callback?callback():null;},(e)=>{alert(e.responseJSON.message);});},logout:function(callback){_self.ajax.call("/api/logout","POST",true,{},(data)=>{_self.loggedIn=false;_self.bearer=null;localStorage.removeItem('access_token');callback?callback():null;},(e)=>{alert(e.responseJSON.message);});},validate:function(callback,error){if(window.external_bearer){_self.auth.waitForBearer=setInterval(()=>{if(!window.access_token)return;_self.bearer=window.access_token;clearInterval(_self.auth.waitForBearer);if(_self.bearer)_self.loggedIn=true;callback?callback():null;},1000);return;} else _self.bearer=localStorage.getItem('access_token');if(_self.bearer)_self.loggedIn=true;callback?callback():null;return _self.bearer;},updatePassword:()=>{if(_self.state.user.curPass.length<8){alert("Invalid password");return;} if(_self.state.user.newPass.length<8){alert("Invalid password");return;} if(_self.state.user.newPass2!=_self.state.user.newPass){alert("New passwords don't match");return;} _self.ajax.call("/api/update-password","POST",true,{oldPass:_self.state.user.curPass,newPass:_self.state.user.newPass},(data)=>{_self.state.user.curPass="";_self.state.user.newPass="";_self.state.user.newPass2="";_self.state.dashboard.sub2page='password-updated';});},resetPassword:()=>{$.post("/api/reset-password",_self.state.user,(data)=>{location.href="https://www.vpark.io";},"json").fail((data)=>{alert("Password reset failed.")});},forgotPassword:()=>{if(!_self.state.user.email||_self.state.user.email.length<6){alert("Please enter a valid email");return;} $.post("/api/forgot-password",_self.state.user,(data)=>{alert(data.message);},"json").fail((e)=>{alert(e.responseJSON.message);});},check2faRequirement:(email,password)=>{if(!_self.state.user.email||_self.state.user.email.length<6){alert("Please enter a valid email");return;} if(!_self.state.user.password||_self.state.user.password.length<8){alert("Password must be at least 8 characters.");return;} if(_self.state.user.secret&&_self.state.user.secret.length>4){_self.scope.login(email,password);return;} $.post("/api/2fa/requirement",_self.state.user,(data)=>{if(data.status_code==200){_self.state.userNeeds2FA=data.google2fa;if(!_self.state.userNeeds2FA)_self.scope.login(email,password);else _self.scope.$apply();} else alert("Login failed: "+data.message);},"json").fail((e)=>{alert(e.responseJSON.message);});},},api:{account:{db:{processing:false},uploadNewProfilePic:()=>{if($('#profilePicSelect')[0].files[0].size>1024*1024){alert("File is too big. 1 MB Max.");return;} var formData=new FormData();formData.append('file',$('#profilePicSelect')[0].files[0]);$.ajax({url:'/api/user/profile/picture',headers:{Authorization:_self.bearer,},type:'POST',data:formData,processData:false,contentType:false,success:function(data){_self.state.user.picture='https://d3o58t2pcb2bu7.cloudfront.net/users/'+_self.state.user.hash+'/thumbnail.jpg';_self.scope.$apply();}});},saveProfile:()=>{if(_self.state.user.url_id&&(_self.state.user.url_id.length<6||!_self.state.user.url_id.match(/^[0-9a-zA-Z_]+$/)))alert("Username must be at least 6 alphanumeric chars");if(_self.state.accountConnectionChanged&&!confirm("To continue, please confirm that you agree to the latest vPark Land's terms and conditions."))return;_self.ajax.call("/api/profile","PUT",true,{name:_self.state.user.name,country:_self.state.user.country,phone:_self.state.user.phone,headline:_self.state.user.headline,url_id:_self.state.user.url_id,vpark_id:_self.state.user.vpark_id,readyplayerme:_self.state.user.readyplayerme,cloth:_self.state.user.cloth,},(data)=>{_self.state.accountConnectionChanged=false;_self.state.vParkUserConnected=_self.state.user.vpark_id;_self.state.user.name=data.name;_self.state.profileUpdated=true;_self.scope.$apply();});},rotateCoupon:(hash)=>{_self.ajax.call("/api/user/coupon/rotates","POST",true,null,(data)=>{_self.state.user.coupon=data.referral;});},setAvatar:(url,callback)=>{_self.ajax.call("/api/profile/avatar","PUT",true,{url:url},(data)=>{callback?callback():null;});},setNotification:(profile,callback)=>{_self.ajax.call("/api/profile/notification","PUT",true,{mail_transaction:profile.mail_transaction,mail_crime:profile.mail_crime,mail_update:profile.mail_update,mail_runners:profile.mail_runners,mail_bio:profile.mail_bio,},(data)=>{callback?callback():null;});},avatarStatus:(callback)=>{_self.ajax.call("/api/profile/avatar/status","GET",true,null,(data)=>{callback?callback(data):null;});},setAvatarLocation:(address,unit,callback)=>{_self.ajax.call("/api/world/player/me/location","PUT",true,{address:address,unit:unit,},(data)=>{callback?callback():null;});},setAvatarLocation2:(hash,x,y,callback)=>{_self.ajax.call("/api/world/player/me/location/hack","PUT",true,{hash:hash,x:x,y:y,},(data)=>{window.ue4('reloadWorldRaw',{hash:hash});callback?callback():null;});},getFinancial:(callback)=>{_self.ajax.call("/api/user/financial","GET",true,null,(data)=>{_self.state.user.financial=data;callback?callback():null;});},buyLife:(callback)=>{if(!_self.loggedIn)return;if(!confirm("You are paying 20000 vDs to ensoul your vHuman. Please confirm to continue."))return;_self.api.account.db.processing=true;_self.ajax.call(`/api/user/biology/life`,"POST",true,(data)=>{_self.api.account.db.processing=false;callback?callback():null;},(data)=>{_self.api.account.db.processing=false;error?error(data):0;});},inviteUser:(hash,address,callback)=>{if(!hash||hash.length<5)return;_self.ajax.call(`/api/world/player/${hash}/invite`,"POST",true,{address:address,},(data)=>{callback?callback():null;});},myInvites:(callback)=>{_self.ajax.call(`/api/world/player/me/invites`,"GET",true,null,(data)=>{callback?callback(data):null;});},cancelInvite:(hash,callback)=>{_self.ajax.call(`/api/world/player/${invite}/invite`,"DELETE",true,null,(data)=>{callback?callback(data):null;});},cancelInvites:(callback)=>{_self.ajax.call(`/api/world/player/invites`,"DELETE",true,null,(data)=>{callback?callback(data):null;});},get2FA:(callback)=>{_self.ajax.call("/api/2fa/google","GET",true,null,(data)=>{_self.state.qr=data;_self.scope.$apply();callback?callback():null;});},setup2FA:(callback)=>{_self.ajax.call("/api/2fa/google","POST",true,null,(data)=>{_self.state.backup_code=data.backup_code;_self.api.account.get2FA(callback);});},verify2FA:(code)=>{if(!code||!code.length)code=prompt("Enter the code from your authenticator app.");_self.ajax.call("/api/2fa/google","PUT",true,{secret:code},(data)=>{_self.state.user.google2fa_verified=true;_self.state.backup_code=null;_self.state.dashboard.sub2page=null;_self.state.user.entered2FA=null;_self.scope.$apply();alert("Your 2FA is now enabled.");});},remove2FA:(code)=>{if(!code||!code.length)code=prompt("Enter the code from your authenticator app.");_self.ajax.call("/api/2fa/google","DELETE",true,{secret:code},(data)=>{_self.state.user.google2fa_verified=false;_self.state.qr=null;_self.state.dashboard.sub2page=null;_self.state.user.entered2FA=null;_self.scope.$apply();alert("Your 2FA is now disabled.");});}},business:{db:{processing:false},contact:(sid,callback,error)=>{if(!_self.state.contact.first||!_self.state.contact.last||!_self.state.contact.title||!_self.state.contact.company||!_self.state.contact.email||!_self.state.contact.country||!_self.state.contact.industry||!_self.state.contact.phone)return;if(_self.api.business.db.processing)return;_self.api.business.db.processing=true;_self.ajax.call(`/api/business/contact`,"POST",false,_self.state.contact,(data)=>{_self.api.business.db.processing=false;_self.state.contact={done:true};_self.scope.$apply();callback?callback(data):0;},(data)=>{_self.api.business.db.processing=false;error?error(data):0;});},bizContact:(sid,callback,error)=>{if(!_self.state.contact.first||!_self.state.contact.last||!_self.state.contact.email||!_self.state.contact.country)return;if(_self.api.business.db.processing)return;_self.api.business.db.processing=true;_self.ajax.call(`/api/business/contact`,"POST",false,_self.state.contact,(data)=>{_self.api.business.db.processing=false;_self.state.contact={done:true};_self.scope.$apply();callback?callback(data):0;},(data)=>{_self.api.business.db.processing=false;error?error(data):0;});},},story:{db:{processing:false},get:(x1,y1,x2,y2,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.story.db.processing)return;if(!x1)[x1,y1,x2,y2]=_self.scope.getMapBound();if(_self.scope.lastRandomLandCoords[0]==x1&&_self.scope.lastRandomLandCoords[1]==y1&&_self.scope.lastRandomLandCoords[2]==x2&&_self.scope.lastRandomLandCoords[3]==y2)return;_self.scope.lastRandomLandCoords=[x1,y1,x2,y2];_self.api.story.db.processing=true;_self.ajax.call(`/api/vhuman/stories/${x1}/${y1}/${x2}/${y2}`,"GET",true,{},(data)=>{_self.api.story.db.processing=false;_self.api.story.db.data=data;if(_self.state.current&&_self.state.current.path=='map/news')_self.state.current.data=data;callback?callback(data):0;},(data)=>{_self.api.story.db.processing=false;error?error(data):0;});},pay:(sid,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.story.db.processing)return;_self.api.story.db.processing=true;_self.ajax.call(`/api/vhuman/stories/${sid}/pay`,"POST",true,{},(data)=>{_self.api.story.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.story.db.processing=false;error?error(data):0;});},close:(sid,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.story.db.processing)return;_self.api.story.db.processing=true;_self.ajax.call(`/api/vhuman/stories/${sid}`,"DELETE",true,{},(data)=>{_self.api.story.db.processing=false;_self.api.story.db.data=_self.api.story.db.data.filter(e=>e.id!=sid);callback?callback(data):0;},(data)=>{_self.api.story.db.processing=false;error?error(data):0;});},fine:(sid,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.story.db.processing)return;let price=prompt("How much vD you are asking? \n30% vPARK Fee Applies.");if(price.length<1)return;_self.api.story.db.processing=true;_self.ajax.call(`/api/vhuman/stories/${sid}/fine`,"POST",true,{amount:parseFloat(price)},(data)=>{_self.api.story.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.story.db.processing=false;error?error(data):0;});},scold:(sid,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.story.db.processing)return;_self.api.story.db.processing=true;_self.ajax.call(`/api/vhuman/stories/${sid}/scold`,"POST",true,{},(data)=>{_self.api.story.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.story.db.processing=false;error?error(data):0;});},punish:(c,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.story.db.processing)return;_self.api.story.db.processing=true;_self.ajax.call(`/api/vhuman/stories/${c.id}/punish`,"POST",true,{},(data)=>{_self.api.story.db.processing=false;c.judged=1;c.jail++;callback?callback(data):0;},(data)=>{_self.api.story.db.processing=false;error?error(data):0;});},},social:{db:{processing:false},post:(blob,filename)=>{if(!_self.loggedIn)return;_self.state.social.new.parent=_self.state.social.new.parent?_self.state.social.new.parent:null;const data={x:_self.state.social.my_gps?_self.state.social.my_gps.x:null,y:_self.state.social.my_gps?_self.state.social.my_gps.y:null,caption:_self.state.social.new.caption,parent:_self.state.social.new.parent,type:_self.state.social.new.type?_self.state.social.new.type:0,hash:_self.state.social.new.hash,playlist_id:_self.state.social.playlist.id,};let fn={0:'recording.mp3',2:'recording.mp3',3:'file.png',};var formData=new FormData();formData.append('data',JSON.stringify(data));if(blob){let file=new File([blob],fn[data.type]);formData.append('file',file);} _self.api.social.db.processing=true;$.ajax({url:'/api/vhuman/posts',headers:{Authorization:_self.bearer,},type:'POST',data:formData,processData:false,contentType:false,success:function(data){_self.api.social.db.processing=false;let p=null;if(_self.state.social.user.vhuman)p=_self.state.social.user.vhuman.posts;else if(_self.state.social.playlist&&_self.state.social.playlist.posts)p=_self.state.social.playlist.posts;let i=p.findIndex(e=>e.hash==data.hash);if(~i)p[i]=data;else p.unshift(data);_self.state.social.new={};},error:(e)=>{alert(e.responseJSON.message);_self.api.social.db.processing=false;},});},user:(hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/user/${hash}`,"GET",true,null,(data)=>{_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},support:(hash,amount,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/${hash}/give`,"POST",true,{amount:amount},(data)=>{_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},delete:(p,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;if(!confirm("Are you sure?"))return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}`,"DELETE",true,null,(data)=>{_self.api.social.db.processing=false;if(_self.state.social.user.vhuman)_self.state.social.user.vhuman.posts=_self.state.social.user.vhuman.posts.filter(e=>e.hash!=p.hash);else if(_self.state.social.playlist&&_self.state.social.playlist.posts)_self.state.social.playlist.posts=_self.state.social.playlist.posts.filter(e=>e.hash!=p.hash);callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},get:(parent,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts${parent? '/'+parent+'/comments' : ''}`,"GET",true,null,(data)=>{_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},comment:(p,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}/comment`,"POST",true,{caption:p.newComment},(data)=>{_self.api.social.db.processing=false;p.comments.unshift(data);p.newComment='';callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},order:(p,step,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}/order`,"PUT",true,{step:step},(data)=>{for(var i in data.updates) _self.state.social.user.vhuman.posts.forEach(e=>{if(e.hash==i)e.order=data.updates[i];}) _self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},updateLocation:(p,callback,error)=>{let x=parseInt(prompt("Enter vPARK X Coord..."));let y=parseInt(prompt("Enter vPARK Y Coord..."));if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}/location`,"PUT",true,{x:x,y:y},(data)=>{p.x=x;p.y=y;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},updateCaption:(p,callback,error)=>{let x=prompt("Enter new caption...");if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}/caption`,"PUT",true,{caption:x},(data)=>{p.caption=x;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},like:(p,value,callback,error)=>{if(value==p.like)return;if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}/like`,"POST",true,{value:value},(data)=>{p.like=value;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},follow:(hash,value,callback,error)=>{if(value==_self.state.social.user.followed)return;if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/${hash}/follow`,"POST",true,{value:value},(data)=>{_self.state.social.user.followed=value;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},playlist:{get:(hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists/${hash}`,"GET",true,null,(data)=>{_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},ask:(hash,caption,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists/${hash}/ask`,"POST",true,{caption:caption},(data)=>{_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},like:(p,value,callback,error)=>{if(value==p.like)return;if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists/${p.hash}/like`,"POST",true,{value:value},(data)=>{p.like=value;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},activate:(p,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists/${p.hash}/activate`,"POST",true,null,(data)=>{p.private=true;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},set:(p,callback,error)=>{if(!confirm("Are you sure?"))return;if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/posts/${p.hash}/playlist`,"POST",true,{playlist_id:p.playlist_id},(data)=>{_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},follow:(p,value,callback,error)=>{if(value&&p.id==_self.state.social.user.listening)return;if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists/${p.hash}/follow`,"POST",true,{value:value},(data)=>{if(value==1){_self.state.social.user.listening=p.id;_self.state.social.user.vhuman.listening=p;} else _self.state.social.user.listening=null;_self.api.social.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},delete:(p,callback,error)=>{if(!confirm("Are you sure?"))return;if(!_self.loggedIn)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists/${p.hash}`,"DELETE",true,null,(data)=>{_self.api.social.db.processing=false;_self.state.social.user.vhuman.playlists=_self.state.social.user.vhuman.playlists.filter(e=>e.hash!=p.hash);callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},create:(callback,error)=>{if(!confirm("Are you sure?"))return;if(!_self.loggedIn)return;if(!_self.state.social.playlist.new||_self.state.social.playlist.new.length<5)return;if(_self.api.social.db.processing)return;_self.api.social.db.processing=true;_self.ajax.call(`/api/vhuman/playlists`,"POST",true,{title:_self.state.social.playlist.new},(data)=>{_self.api.social.db.processing=false;_self.state.social.user.vhuman.playlists.push(data);_self.state.social.playlist.new=null;callback?callback(data):0;},(data)=>{_self.api.social.db.processing=false;error?error(data):0;});},}},route:{db:{processing:false},mine:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/mine`,"GET",true,null,(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},create:(callback,error)=>{let name=prompt("Enter a new route name");if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes`,"POST",true,{name:name},(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},update:(r,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/${r.hash}`,"PUT",true,r,(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},get:(hash,min_dist,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/${hash}?min_distance=${min_dist}`,"GET",true,null,(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},add:(hash,props,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/${hash}/add`,"POST",true,{properties:props},(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},remove:(hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/${hash}/remove`,"POST",true,null,(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},clear:(hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/${hash}/clear`,"POST",true,null,(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},delete:(hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.route.db.processing)return;_self.api.route.db.processing=true;_self.ajax.call(`/api/run/routes/${hash}`,"DELETE",true,null,(data)=>{_self.api.route.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.route.db.processing=false;error?error(data):0;});},},realestate:{db:{processing:false},getMyAccess:(property_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/${property_hash}/access/me`,"GET",true,null,(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},rent:(property_hash,days,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;days=parseInt(days);_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/${property_hash}/rent`,"POST",true,{days:days},(data)=>{_self.api.realestate.processing=false;_self.api.realestate.db.unit=data.hash;_self.state.world.realestate.access=true;_self.state.world.realestate.success=true;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},editor:{getAssets:(property_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.db.processing)return;_self.api.realestate.db.processing=true;_self.ajax.call(`/api/properties/${property_hash}/assets`,"GET",true,null,(data)=>{_self.api.realestate.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.db.processing=false;error?error(data):0;});},updateAssets:(property_hash,elements,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.db.processing)return;_self.api.realestate.db.processing=true;_self.ajax.call(`/api/properties/${property_hash}/assets`,"PUT",true,{elements:elements},(data)=>{_self.api.realestate.db.processing=false;callback?callback(data):0;if(window.ue4)ue4('editor',{cmd:'refresh',data:elements});},(data)=>{_self.api.realestate.db.processing=false;error?error(data):0;});},},installation:{getInstallables:(element_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/installations/${element_hash}/matched`,"GET",true,null,(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},install:(bag_hash,element_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/installations/${element_hash}/${bag_hash}`,"PUT",true,null,(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},setPrice:(element_hash,price,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/installations/${element_hash}/price`,"POST",true,{price:price},(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},counterfeit:(element_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/installations/${element_hash}/counterfeit`,"POST",true,{},(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},buy:(element_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/installations/${element_hash}/buy`,"POST",true,{},(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},remove:(element_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.realestate.processing)return;_self.api.realestate.processing=true;_self.ajax.call(`/api/properties/installations/${element_hash}`,"DELETE",true,null,(data)=>{_self.api.realestate.processing=false;callback?callback(data):0;},(data)=>{_self.api.realestate.processing=false;error?error(data):0;});},},},bio:{db:{processing:false},sleep:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bio.processing)return;_self.api.bio.processing=true;_self.ajax.call(`/api/user/biology/sleep`,"POST",true,null,(data)=>{_self.api.bio.processing=false;callback?callback(data):0;},(data)=>{_self.api.bio.processing=false;error?error(data):0;});},kill:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bio.processing)return;if(!confirm("Please confirm you want to let this vHuman die. Various access, goods and real estates may go away. This action is final."))return;_self.api.bio.processing=true;_self.ajax.call(`/api/user/biology/kill`,"POST",true,null,(data)=>{_self.api.bio.processing=false;callback?callback(data):0;},(data)=>{_self.api.bio.processing=false;error?error(data):0;});},wakeup:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bio.processing)return;_self.api.bio.processing=true;_self.ajax.call(`/api/user/biology/wakeup`,"POST",true,null,(data)=>{_self.api.bio.processing=false;callback?callback(data):0;},(data)=>{_self.api.bio.processing=false;error?error(data):0;});},stamina:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bio.processing)return;_self.api.bio.processing=true;_self.ajax.call(`/api/user/biology/status`,"GET",true,null,(data)=>{_self.api.bio.processing=false;callback?callback(data):0;},(data)=>{_self.api.bio.processing=false;error?error(data):0;});},},bag:{db:{processing:false},list:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bag.processing)return;_self.api.bag.processing=true;_self.ajax.call(`/api/user/bag`,"GET",true,null,(data)=>{_self.api.bag.processing=false;callback?callback(data):0;},(data)=>{_self.api.bag.processing=false;error?error(data):0;});},consume:(bag_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bag.processing)return;_self.api.bag.processing=true;_self.ajax.call(`/api/user/bag/${bag_hash}/consume`,"POST",true,null,(data)=>{_self.api.bag.processing=false;callback?callback(data):0;},(data)=>{_self.api.bag.processing=false;error?error(data):0;});},unequip:(bag_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bag.processing)return;_self.api.bag.processing=true;_self.ajax.call(`/api/user/bag/${bag_hash}/unequip`,"POST",true,{element:null},(data)=>{_self.api.bag.processing=false;callback?callback(data):0;},(data)=>{_self.api.bag.processing=false;error?error(data):0;});},equip:(bag_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bag.processing)return;_self.api.bag.processing=true;_self.ajax.call(`/api/user/bag/${bag_hash}/equip`,"POST",true,null,(data)=>{_self.api.bag.processing=false;callback?callback(data):0;},(data)=>{_self.api.bag.processing=false;error?error(data):0;});},delete:(bag_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.bag.processing)return;_self.api.bag.processing=true;_self.ajax.call(`/api/user/bag/${bag_hash}`,"DELETE",true,null,(data)=>{_self.api.bag.processing=false;callback?callback(data):0;},(data)=>{_self.api.bag.processing=false;error?error(data):0;});},},fundraise:{db:{processing:false},mine:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.state.world.fundraise.campaigns=[];_self.ajax.call(`/api/commerce/campaigns/mine`,"GET",true,null,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.campaigns=data;_self.api.nft.mine();},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},availableRoutes:(callback,error)=>{if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.state.world.fundraise.routes=[];_self.ajax.call(`/api/run/routes`,"GET",false,null,(data)=>{_self.api.fundraise.db.processing=false;_self.state.world.fundraise.routes=data;callback?callback(data):0;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},myFundraisings:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.state.world.fundraise.campaigns=[];_self.ajax.call(`/api/commerce/campaigns/fundraisings/mine`,"GET",true,null,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.campaigns=data;for(d in data)data[d].open=data[d].open?moment.tz(data[d].open,'America/Los_Angeles').toDate():null;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},list:(callback,error)=>{if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.state.world.fundraise.campaigns=[];_self.ajax.call(`/api/commerce/campaigns/available`,"GET",false,null,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.campaigns=data;_self.api.nft.mine();},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},getCampaign:(hash,callback,error)=>{if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/${hash}`,"GET",false,null,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;if(!_self.state.world.fundraise)_self.state.world.fundraise={campaign:null,campaigns:[]};_self.state.world.fundraise.campaign=data;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},getResult:(hash,callback,error)=>{if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/${hash}/results`,"GET",false,null,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;if(!_self.state.world.fundraise)_self.state.world.fundraise={campaign:{hash:hash},campaigns:[]};_self.state.world.fundraise.results=data;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},getFundraising:(hash,callback,error,bag=1)=>{if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/fundraisings/${hash}`,"GET",true,null,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;if(!_self.state.world.fundraise)_self.state.world.fundraise={campaign:null,campaigns:[]};data.costreamers=0;data.pledges=0;for(var i in data.reviews){if(_self.state.user&&data.reviews[i].url_id==_self.state.user.url_id){data.like=data.reviews[i].like;data.pledge=data.reviews[i].pledge;} data.costreamers+=data.reviews[i].like?data.reviews[i].like:0;data.pledges+=data.reviews[i].pledge>0?1:0;data.reviews[i].x=Math.random();data.reviews[i].y=Math.random();} _self.state.world.fundraise.campaign=data;if(_self.loggedIn&&bag)_self.api.bag.list((d)=>{_self.state.world.bag.items=d;});_self.scope.$apply();},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},support:(hash,callback,error)=>{if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/fundraisings/${hash}/join`,"POST",true,{like:_self.state.world.fundraise.campaign.like,pledge:_self.state.world.fundraise.campaign.pledge},(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.api.fundraise.getFundraising(hash,null,null,0);},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},give:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/fundraisings/${_self.state.world.fundraise.campaign.hash}`,"POST",true,_self.state.world.fundraise.campaign,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.campaign=data;_self.state.world.fundraise.campaign.gave=true;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},createCampaign:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns`,"POST",true,_self.state.world.fundraise.campaign,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.api.fundraise.mine();_self.state.world.fundraise.campaign={};},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},joinCampaign:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.state.world.fundraise.campaign.timezone=_self.ajax.call(`/api/commerce/campaigns/${_self.state.world.fundraise.campaign.hash}`,"POST",true,_self.state.world.fundraise.campaign,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.campaign={};fbq('track','Purchase',{currency:"USD",value:5});gtag('event','conversion',{'currency':'USD','value':5});gtag('event','conversion',{'send_to':'AW-782748339/LB-ZCL25qO0BELOVn_UC'});mixpanel.track("Joined a race",{"button":"buy"});},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},updateFundraising:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/fundraisings/${_self.state.world.fundraise.campaign.hash}`,"PUT",true,_self.state.world.fundraise.campaign,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},sponsorCampaign:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/${_self.state.world.fundraise.campaign.hash}/sponsor`,"POST",true,_self.state.world.fundraise.sponsor,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.sponsor={cap:10000,target:1000};_self.state.world.fundraise.sponsor.gave=true;},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},updateCampaign:(callback,error)=>{if(!_self.loggedIn)return;if(_self.api.fundraise.db.processing)return;_self.api.fundraise.db.processing=true;_self.ajax.call(`/api/commerce/campaigns/${_self.state.world.fundraise.campaign.hash}`,"PUT",true,_self.state.world.fundraise.campaign,(data)=>{_self.api.fundraise.db.processing=false;callback?callback(data):0;_self.state.world.fundraise.campaign={};},(data)=>{_self.api.fundraise.db.processing=false;error?error(data):0;});},},shop:{db:{processing:false},list:(store_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;_self.api.shop.processing=true;_self.ajax.call(`/api/commerce/stores/${store_hash}/products`,"GET",true,null,(data)=>{_self.api.shop.processing=false;callback?callback(data):0;_self.state.world.shop.items=data.inventories;_self.state.world.shop.buy=data.inventories.filter(e=>(e.transaction_type&1)>0);_self.state.world.shop.supply=data.inventories.filter(e=>(e.transaction_type&2)>0);_self.state.world.shop.storage=_self.state.world.shop.buy;_self.state.world.shop.bag=data.bags;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},buyBulk:(items,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;_self.api.shop.processing=true;_self.ajax.call(`/api/commerce/order/bulk`,"POST",true,{items:items},(data)=>{_self.api.shop.processing=false;callback?callback(data):0;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},sell:(items,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;_self.api.shop.processing=true;_self.ajax.call(`/api/commerce/sell/bulk`,"POST",true,{items:items},(data)=>{_self.api.shop.processing=false;callback?callback(data):0;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},store:(store_hash,bag_hash,quantity,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;_self.api.shop.processing=true;_self.ajax.call(`/api/commerce/stores/${store_hash}/add/${bag_hash}`,"POST",true,{quantity:quantity},(data)=>{_self.api.shop.processing=false;callback?callback(data):0;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},takeout:(store_hash,inventory_hash,quantity,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;_self.api.shop.processing=true;_self.ajax.call(`/api/commerce/stores/${store_hash}/remove/${inventory_hash}`,"POST",true,{quantity:quantity},(data)=>{_self.api.shop.processing=false;callback?callback(data):0;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},setPrice:(store_hash,inventory_hash,price,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;_self.api.shop.processing=true;_self.ajax.call(`/api/commerce/stores/${store_hash}/price/${inventory_hash}`,"put",true,{price:price},(data)=>{_self.api.shop.processing=false;callback?callback(data):0;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},setInventoryPrice:(inventory_hash,callback,error)=>{if(!_self.loggedIn)return;if(_self.api.shop.processing)return;var s=prompt("Enter a new price for this item in vD currency.");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid price");return;} _self.api.shop.processing=true;_self.ajax.call(`/api/commerce/inventories/${inventory_hash}/price`,"put",true,{price:s},(data)=>{_self.api.shop.processing=false;callback?callback(data):0;},(data)=>{_self.api.shop.processing=false;error?error(data):0;});},},wallet:{deposit:()=>{if(_self.state.amountToDeposit<3)return;if(isNaN(_self.state.amountToDeposit))return;_self.ajax.call("/api/land/order","POST",true,{action:"deposit",total:_self.state.amountToDeposit},(data)=>{location.href=data.result.links.find(e=>e.rel=='approve'&&e.method=="GET").href;});},checkWithdrawal:()=>{_self.ajax.call("/api/profile/payout","GET",true,null,(data)=>{_self.state.payout=data;_self.scope.$apply();});},withdraw:()=>{if(_self.state.amountToWithdraw!==0){if(_self.state.amountToWithdraw<50)return;if(_self.state.amountToWithdraw>1500)return;if(isNaN(_self.state.amountToWithdraw))return;} _self.ajax.call("/api/profile/payout","POST",true,{amount:_self.state.amountToWithdraw},(data)=>{_self.state.payout=data;_self.scope.$apply();});},loadTransactions:(offset,callback)=>{if(!_self.loggedIn){return;} if(_self.state.transactions){offset=Math.min(Math.floor(offset / _self.state.transactions.limit)*_self.state.transactions.limit,Math.floor((_self.state.transactions.total-1)/ _self.state.transactions.limit)*_self.state.transactions.limit);offset=Math.max(offset,0);if(offset==_self.state.transactions.offset)return;} _self.ajax.call("/api/profile/transaction/history/"+offset,"GET",true,null,(data)=>{data.offset=parseInt(data.offset);data.total=parseInt(data.total);data.limit=parseInt(data.limit);_self.state.transactions=data;_self.scope.$apply();callback?callback():0;});},tipalti:{url:()=>{if(!_self.state.user.verified){alert("Please verify your ID first.");return;} _self.ajax.call("/api/profile/verification/tax/tipalti/url","GET",true,null,(data)=>{window.open(data);_self.state.tipaltiWidgetUrl=data;_self.scope.$apply();});},status:()=>{_self.ajax.call("/api/profile/verification/tax/tipalti/status","GET",true,null,(data)=>{if(data.message=="SUBMITTED"||data.message=="SUBMITTED (TIN_VALIDATED)"){_self.state.user.tax_verified=true;} else{alert("If you have submitted an entry, your verification in progress. Otherwise please make a submission.");} _self.scope.$apply();});},},diamond:{db:{processing:false},getStats:(callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/diamond/stats`,"GET",true,null,(data)=>{_self.state.diamond.exchange.stats=data;callback?callback(data):0;},()=>{});},getHistory:(step,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/diamond/history/price?step=${step}`,"GET",true,null,(data)=>{_self.state.diamond.exchange.history=data;callback?callback(data):0;},()=>{});},getWallet:(callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/diamond/balance`,"GET",true,null,(data)=>{_self.state.diamond.exchange.balance=data;_self.state.user.cash=data.usd;_self.state.user.voken=data.diamonds;callback?callback(data):0;},()=>{});},getBuyEstimate:(usd,room,callback)=>{if(!isPositiveNumeric(usd))return;if(_self.api.wallet.diamond.processing)return;_self.api.wallet.diamond.processing=1;_self.ajax.call(`/api/diamond/buy?usd=${usd}&cd=${room}`,"GET",true,null,(data)=>{_self.api.wallet.diamond.processing=0;if(!data.diamonds)return;_self.state.diamond.exchange.estimate=data;callback?callback(data):0;},()=>{_self.api.wallet.diamond.processing=0;});},getSellEstimate:(diamonds,callback)=>{if(!isPositiveNumeric(diamonds))return;if(_self.api.wallet.diamond.processing)return;_self.api.wallet.diamond.processing=1;_self.ajax.call(`/api/diamond/sell?diamonds=${diamonds}`,"GET",true,null,(data)=>{_self.api.wallet.diamond.processing=0;if(!data.net_income)return;_self.state.diamond.exchange.estimate=data;callback?callback(data):0;},()=>{_self.api.wallet.diamond.processing=0;});},getSendEstimate:(address,diamonds,callback)=>{if(!isPositiveNumeric(diamonds)||!address||address.length<10)return;if(_self.api.wallet.diamond.processing)return;_self.api.wallet.diamond.processing=1;_self.ajax.call(`/api/diamond/send?diamonds=${diamonds}&address=${address}`,"GET",true,null,(data)=>{_self.api.wallet.diamond.processing=0;if(!data.transfer)return;_self.state.diamond.exchange.estimate=data;callback?callback(data):0;},()=>{_self.api.wallet.diamond.processing=0;});},buy:(usd,room,callback)=>{if(!isPositiveNumeric(usd))return;if(_self.api.wallet.diamond.processing)return;_self.api.wallet.diamond.processing=1;_self.state.diamond.exchange.result=null;_self.ajax.call(`/api/diamond/buy`,"POST",true,{usd:usd,cd:room},(data)=>{_self.state.diamond.exchange.result=data;_self.api.wallet.diamond.processing=0;callback?callback(data):0;},()=>{_self.api.wallet.diamond.processing=0;});return{};},sell:(diamonds,callback)=>{if(!isPositiveNumeric(diamonds))return;if(_self.api.wallet.diamond.processing)return;_self.api.wallet.diamond.processing=1;_self.state.diamond.exchange.result=null;_self.ajax.call(`/api/diamond/sell`,"POST",true,{diamonds:diamonds},(data)=>{_self.state.diamond.exchange.result=data;_self.api.wallet.diamond.processing=0;callback?callback(data):0;},()=>{_self.api.wallet.diamond.processing=0;});return{};},send:(address,diamonds,callback)=>{if(!isPositiveNumeric(diamonds)||!address||address.length<10)return;if(_self.api.wallet.diamond.processing)return;_self.api.wallet.diamond.processing=1;_self.state.diamond.exchange.result=null;_self.ajax.call(`/api/diamond/send`,"POST",true,{diamonds:diamonds,address:address},(data)=>{_self.state.diamond.exchange.result=data;_self.api.wallet.diamond.processing=0;callback?callback(data):0;},()=>{_self.api.wallet.diamond.processing=0;});return{};},},},digicard:{search:'',sort:"date",asc:1,filter:'',submitting:false,create:()=>{if(_self.api.digicard.submitting)return;if(!_self.loggedIn)return;if(_self.state.digicards.newCard.royalty<1||_self.state.digicards.newCard.royalty>20)return;if(_self.state.digicards.newCard.title.length<3)return;if(!_self.state.digicards.newCard.agree)return;_self.state.digicards.newCard.makeCDT='make_cdt';var formData=new FormData();let input=$('#digicard_file')[0];if(!input.files.length)return;let tinput=$('#digicard_u')[0];if(!tinput.files.length)return;formData.append('orig',input.files[0]);formData.append('thumbnail',tinput.files[0]);formData.append('code',"cdt");formData.append('title',_self.state.digicards.newCard.title);formData.append('website',_self.state.digicards.newCard.website?_self.state.digicards.newCard.website:'');formData.append('description',_self.state.digicards.newCard.description?_self.state.digicards.newCard.description:'');formData.append('thumb_filetype',tinput.value.split('.').pop().toLowerCase());formData.append('filetype',input.value.split('.').pop().toLowerCase());_self.api.digicard.submitting=true;_self.scope.zoomToSpace();_self.scope.showCreationProgress();gtag('event','conversion',{'currency':'USD','value':1});gtag('event','conversion',{'send_to':'AW-782748339/LB-ZCL25qO0BELOVn_UC'});$.ajax({url:`/api/digicard/card`,headers:{Authorization:_self.bearer,},method:"POST",data:formData,processData:false,contentType:false,success:function(data,textStatus,xhr){_self.api.digicard.submitting=false;fbq('track','SubmitApplication');_self.state.digicards.newCard={royalty:10};$('#digicard_file')[0].value='';$('#digicard_thumb')[0].value='';$("#new_digicard_thumb_prev").css("background","url(/images/icons/dachshund.svg) no-repeat center center / 50%");$("#new_digicard_thumb_prev").css("background-color","transparent");$("#new_digicard_thumbnail").css("background","transparent");if(_self.state.user.my_cdts)_self.state.user.my_cdts.push(data);_self.scope.$apply();_self.scope.hideCreationProgress();alert("Your asset(s) have been created and is available in the artwork section page.");},error:function(data){_self.api.digicard.submitting=false;alert(data.responseJSON.message);}});},delete:(card,callback)=>{if(!confirm("Please confirm you want to delete this card. This action is final."))return;if(_self.api.digicard.submitting)return;_self.api.digicard.submitting=true;_self.ajax.call(`/api/digicard/card/${card.hash}`,"DELETE",true,null,(data)=>{_self.api.digicard.submitting=false;_self.state.user.my_digicards=_self.state.user.my_digicards.filter(e=>e.id!=card.id);let x=$('#digicard_file');if(x&&x.length)x[0].value='';_self.scope.$apply();callback?callback():0;},()=>{_self.api.digicard.submitting=false;});},submitForex:(content)=>{if(!confirm("Please confirm you want to invest at least USD $2,500. We will share your email for ForexAutoPilot to contact you. Depending on your country of residence, SmartX bot brokers might not be able to accommodate you. You'll earn cashback by registering through us, 25% from the bot fee commission SmartX is giving us. Please make sure you have read mission #2 before continuing."))return;_self.ajax.call(`/api/digicard/smartx/${content.id}/submit`,"POST",true,null,(data)=>{alert("Submission successful.");});},buy:(content)=>{if(!confirm("Please confirm you want to buy this digicard. This action is final and non-refundable. Terms and conditions apply."))return;_self.ajax.call(`/api/digicard/card/${content.digicard}/content/${content.id}/buy`,"POST",true,null,(data)=>{alert("Purchase successful.");});},sell:(card)=>{if(!_self.state.loggedIn)return;var s=prompt("Enter a desired minimum price in USD ($10 min) to sell this DigiCard. Once this card is set with a minimum price, you cannot change the price or cancel the listing.");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid price");return;} s=parseInt(s);if(s<10){alert("A price of a DigiCard artwork must be at least $10");return;} _self.ajax.call(`/api/digicard/card/${card.hash}/price`,"PUT",true,{price:s},(data)=>{card.listed=s;_self.scope.$apply();});},like:(card)=>{if(!_self.state.loggedIn)return;_self.ajax.call(`/api/digicard/card/${card.hash}/like`,"POST",true,null,(data)=>{card.likes=data;_self.scope.$apply();});},list:(offset=0,limit=28,callback)=>{_self.state.digicards.showDigicards=true;_self.state.usableDigicards=[];_self.ajax.call(`/api/digicard/cards/${offset}/${limit}?sort=${_self.api.digicard.sort}&sort_asc=${_self.api.digicard.asc? 1:0}&filter=${_self.api.digicard.filter}&search=${_self.api.digicard.search}`,"GET",true,null,(data)=>{_self.state.usableDigicards=data.data;_self.state.db.digicards=data;_self.scope.$apply();});callback?callback():0;},getMine:(callback)=>{if(!_self.state.loggedIn)return;_self.ajax.call(`/api/digicard/cards/mine`,"GET",true,null,(data)=>{_self.state.user.digicards=data.created;_self.state.user.my_digicards=data.purchased;_self.state.user.total_nft_likes=0;data.created.map(e=>{_self.state.user.total_nft_likes+=e.likes;}) data.purchased.map(e=>{_self.state.user.total_nft_likes+=e.likes;}) _self.scope.$apply();callback?callback():null;});}},nft:{search:'',sort:"date",asc:1,filter:'',submitting:false,afropunk:{db:{price:0},getPrice:()=>{_self.ajax.call(`/api/nft/creation/afropunk/price`,"GET",true,null,(data)=>{_self.api.nft.afropunk.db.price=parseInt(data.price);_self.api.nft.afropunk.db.available=parseInt(data.available);});},purchase:(img,callback)=>{if(!_self.loggedIn)return;if(window.afroupdated<10){alert("Please customize the afro punk more.");return-1;} if(!confirm("Please confirm you want to claim this afro punk. This action is final. Please wait after confirming and do not click the claim button again or you might get charged twice."))return-1;_self.ajax.call(`/api/nft/creation/afropunk/price`,"GET",true,null,(data)=>{if(_self.api.nft.afropunk.db.price!=parseInt(data.price)&&!confirm("Others have also claimed another Afropunk, the price has changed and it now costs $"+parseInt(data.price)))return;_self.api.nft.afropunk.db.price=parseInt(data.price);_self.api.nft.afropunk.db.available=parseInt(data.available);_self.ajax.call(`/api/nft/creation/afropunk/purchase`,"POST",true,null,(data)=>{if(_self.api.digicard.submitting)return;var formData=new FormData();formData.append('orig',dataURItoBlob(img));formData.append('thumbnail',dataURItoBlob(img));formData.append('code',"vpark_nft");formData.append('title',data.title);formData.append('royalty',10);formData.append('website','https://www.vpark.io');formData.append('description','Unique collectible characters with proof of ownership stored on the vPark blockchain. This project is run by vPark.');formData.append('thumb_filetype',"png");formData.append('filetype',"png");_self.api.digicard.submitting=true;_self.scope.zoomToSpace();_self.scope.showCreationProgress(img);$.ajax({url:`/api/digicard/card`,headers:{Authorization:_self.bearer,},method:"POST",data:formData,processData:false,contentType:false,success:function(data,textStatus,xhr){_self.api.digicard.submitting=false;_self.state.digicards.newCard={royalty:10};_self.state.user.my_digicards.push(data);_self.scope.$apply();_self.scope.hideCreationProgress();alert("Your DigiCard has been created and can be seen under the My DigiCard page. Don't forget to set price for your NFT & DigiCard. You can also now join the Afro Punk Club chat in New York City area. Invite your friends to join and share your afropunk on social media.");callback?callback():0;},error:function(data){_self.api.digicard.submitting=false;alert(data.responseJSON.message);}});});});},},get:(hash,callback)=>{_self.ajax.call(`/api/digicard/cdt/${hash}`,"GET",false,null,(data)=>{_self.state.selectedDigicard=data;_self.scope.$apply();callback?callback():0;});},list:(offset=0,limit=28,callback)=>{_self.state.shop.showDigicards=true;_self.state.usableCDTs=[];_self.ajax.call(`/api/digicard/cdt/0/${offset}/${limit}?sort=${_self.api.nft.sort}&sort_asc=${_self.api.nft.asc? 1:0}&filter=${_self.api.nft.filter}&search=${_self.api.nft.search}`,"GET",false,null,(data)=>{_self.state.usableCDTs=data.data;_self.state.db.cdts=data;_self.scope.$apply();callback?callback():0;});},mine:(callback)=>{if(!_self.state.loggedIn)return;_self.ajax.call(`/api/digicard/cdts/mine`,"GET",true,null,(data)=>{_self.state.user.cdts=data.created;_self.state.user.my_cdts=data.purchased;_self.scope.$apply();callback?callback():null;});},sell:(card)=>{if(!_self.state.loggedIn)return;var s=prompt("Enter a desired price in USD ($10 min) to sell this artwork.");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid price");return;} s=parseInt(s);if(s<10){alert("A price of a CDT must be at least $10");return;} _self.ajax.call(`/api/digicard/card/${card.hash}/price`,"PUT",true,{price:s},(data)=>{card.listed=s;_self.scope.$apply();});},delete:(card,callback)=>{if(!confirm("Please confirm you want to delete this CDT. This action is final."))return;if(_self.api.nft.submitting)return;_self.api.nft.submitting=true;_self.ajax.call(`/api/digicard/card/${card.hash}`,"DELETE",true,null,(data)=>{_self.api.nft.submitting=false;_self.state.user.my_cdts=_self.state.user.my_cdts.filter(e=>e.id!=card.id);let x=$('#digicard_file');if(x&&x.length)x[0].value='';_self.scope.$apply();callback?callback():0;},()=>{_self.api.nft.submitting=false;});},buy:(c,callback)=>{if(!confirm("Please confirm you want to buy this collectible digital item. This action is final and non-refundable. Terms and conditions apply."))return;_self.ajax.call(`/api/digicard/cdt/0/${c.hash}/buy`,"POST",true,null,(data)=>{alert("Purchase successful.");callback?callback():0;});},transfer:(c,callback)=>{var rec=prompt("Enter recipient's user hash you want to give this NFT to.");if(!rec||rec.length<10)return;if(!confirm("Please confirm you want to transfer this nft. This action is final and non-refundable. Terms and conditions apply."))return;_self.ajax.call(`/api/digicard/cdt/0/${c.hash}/transfer`,"POST",true,{recipient:rec},(data)=>{alert("Transfer successful.");callback?callback():0;});}},digitalGoods:{search:'',sort:"date",asc:1,filter:'',submitting:false,mine:(callback)=>{if(!_self.state.loggedIn)return;_self.ajax.call(`/api/world/collections/3d/mine`,"GET",true,null,(data)=>{_self.state.user.my_goods=data.purchased;_self.scope.$apply();callback?callback():null;});},sell:(c)=>{if(!_self.state.loggedIn)return;var s=prompt("Enter a desired price in 1000 vD to sell this item.");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid price");return;} s=parseInt(s);if(s<10){alert("A price of a digital good must be at least 1000 vD");return;} _self.ajax.call(`/api/world/collections/3d/${c.hash}/price`,"PUT",true,{price:s},(data)=>{c.listed=s;_self.scope.$apply();});},buy:(c,callback)=>{if(!confirm("Please confirm you want to buy this collectible digital item. This action is final and non-refundable. Terms and conditions apply."))return;_self.ajax.call(`/api/world/collections/3d/${c.hash}/buy`,"POST",true,null,(data)=>{alert("Purchase successful.");callback?callback():0;});},delete:(card,callback)=>{if(!confirm("Please confirm you want to delete this item. This action is final."))return;if(_self.api.digitalGoods.submitting)return;_self.api.digitalGoods.submitting=true;_self.ajax.call(`/api/world/collections/3d/${card.hash}`,"DELETE",true,null,(data)=>{_self.api.digitalGoods.submitting=false;_self.state.user.my_cdts=_self.state.user.my_cdts.filter(e=>e.id!=card.id);let x=$('#digicard_file');if(x&&x.length)x[0].value='';_self.scope.$apply();callback?callback():0;},()=>{_self.api.digitalGoods.submitting=false;});},transfer:(c,callback)=>{var rec=prompt("Enter recipient's user hash you want to give this item to.");if(!rec||rec.length<10)return;if(!confirm("Please confirm you want to transfer this good. This action is final and non-refundable. Terms and conditions apply."))return;_self.ajax.call(`/api/world/collections/3d/${c.hash}/transfer`,"POST",true,{recipient:rec},(data)=>{alert("Transfer successful.");callback?callback():0;});}},land:{getLandPrice:(x,y)=>{_self.ajax.call("/api/land/price/"+x+"/"+y,"GET",true,null,(data)=>{_self.state.landInfo=data;if(_self.state.landInfo.price<=0)alert("Land in this area not available.");});},getCountryPrice:(country)=>{if(_self.state.countryPrices[country])return _self.state.countryPrices[country].price;_self.state.countryPrices[country]={price:0.1};_self.ajax.call("/api/land/price/"+country,"GET",true,null,(data)=>{_self.state.countryPrices[country]=data;_self.scope.$apply();});return 0.1;},setGroupName:(group_id,callback)=>{let newName=prompt("Enter new name");if(newName.length<1)return;_self.ajax.call("/api/land/"+group_id+"/rename","PUT",true,{title:newName},(data)=>{newName=data.title;let g=_self.state.user.lands.find(e=>e.group_id==group_id);if(g)g.title=newName;if(_self.state.selectedGroup&&_self.state.selectedGroup.group_id==group_id)_self.state.selectedGroup.title=newName;_self.scope.$apply();});},showPurchase:(s,group_id,callback,updatemap=true)=>{if(s){let sqrData=_self.scope.getOccupiedSquareData(s);group_id=sqrData.group_id;} _self.api.land.clearPreparedLands();_self.ajax.call("/api/land/"+group_id,"GET",true,null,(data)=>{_self.state.selectedGroup=data;if(updatemap) _self.state.pages=["map","land",group_id];_self.scope.$apply();callback?callback():null;});},prepareLand:()=>{if(_self.state.landPrepared)return;if(new Date()-_self.scope.buyLandTick<1000)return;if(_self.state.preparingLand)return;_self.scope.buyLandTick=new Date();_self.state.preparingLand=true;fbq('track','InitiateCheckout',{currency:"USD",value:1});mixpanel.track("Land Prepare",{"button":"Prepare"});_self.ajax.call("/api/land","POST",true,{lands:_self.state.selectedSquares},(data)=>{[data.x,data.y]=_self.state.selectedSquares[0].split("-");_self.state.landPrepared=data;_self.state.selectedGroup=data;_self.state.pages=["map","land",data.group_id];_self.state.preparingLand=false;_self.scope.$apply();},(data)=>{_self.state.landPrepared=true;_self.state.preparingLand=false;_self.api.land.clearPreparedLands();});},buyLand:()=>{if(!_self.state.selectedGroup)return;if(_self.state.landPrepared!==_self.state.selectedGroup&&_self.state.selectedGroup.listed==0)return;if(_self.state.user.hash==_self.state.selectedGroup.buyer_hash)return;if(_self.state.user.cash+_self.state.user.valuation+_self.state.selectedGroup.price<50)alert("This is a courtesy reminder that there is a minimum withdrawal amount and fee associated with it. Your purchase amount and account balance are low, make sure you can sell it above the minimum withdrawal if you intent to sell it soon.");if(!confirm("Are you sure you want to buy this land squares? No cancellation allowed."))return;fbq('track','Purchase',{currency:"USD",value:_self.state.selectedGroup.listed});gtag('event','conversion',{'currency':'USD','value':_self.state.selectedGroup.listed});gtag('event','conversion',{'send_to':'AW-782748339/LB-ZCL25qO0BELOVn_UC'});mixpanel.track("Land Purchase",{"button":"buy"});_self.state.loading=true;_self.ajax.call("/api/land/order","POST",true,{action:_self.state.selectedGroup.group_id,coupon:_self.state.coupon_code},(data)=>{location.href=data.result.links.find(e=>e.rel=='approve'&&e.method=="GET").href;},(data)=>{_self.state.loading=false;_self.scope.$apply();});_self.scope.$apply();},buyLandWithCash:(callback)=>{if(!_self.state.loggedIn){alert("Please login");return;} if(!_self.state.selectedGroup)return;if(_self.state.landPrepared!==_self.state.selectedGroup&&_self.state.selectedGroup.listed==0)return;if(_self.state.user.hash==_self.state.selectedGroup.buyer_hash)return;if(_self.state.user.cash+_self.state.user.valuation+_self.state.selectedGroup.price<50)alert("This is a courtesy reminder that there is a minimum withdrawal amount and fee associated with it. Your purchase amount and account balance are low, make sure you can sell it above the minimum withdrawal if you intent to sell it soon.");if(_self.state.selectedGroup.stamped&&!confirm("[IMPORTANT NOTICE]\n\nThis land has been stamped by another user, there will be different commission fee and royalty that come along with your future resale. I declare that I am fully aware about the difference between unstamped and stamped lands."))return;if(!confirm("Are you sure you want to buy this land squares? No cancellation allowed."))return;_self.state.loading=true;_self.ajax.call("/api/land/"+_self.state.selectedGroup.group_id,"POST",true,{coupon:_self.state.coupon_code},(data)=>{let pr=_self.state.selectedGroup.bidded_price?_self.state.selectedGroup.bidded_price:_self.state.selectedGroup.listed;fbq('track','Purchase',{currency:"USD",value:pr});gtag('event','conversion',{'currency':'USD','value':pr});gtag('event','conversion',{'send_to':'AW-782748339/LB-ZCL25qO0BELOVn_UC'});mixpanel.track("Land Purchase",{"button":"buy"});_self.state.coupon_code=null;_self.state.loading=false;_self.api.land.showPurchase(null,_self.state.selectedGroup.group_id);_self.scope.clearSelected();_self.scope.clearGridCache();_self.scope.refreshGrid(1);_self.scope.validate(0);callback?callback():null;},(data)=>{_self.state.loading=false;_self.scope.$apply();});},rent:(callback)=>{if(!_self.state.loggedIn)return;if(!_self.state.selectedGroup)return;if(_self.state.landPrepared!==_self.state.selectedGroup&&_self.state.selectedGroup.lease_price==0)return;if(!confirm("Are you sure you want to rent this land group for +30 days?"))return;_self.state.loading=true;_self.ajax.call(`/api/land/${_self.state.selectedGroup.group_id}/rent`,"POST",true,{},(data)=>{_self.state.loading=false;callback?callback():null;},(data)=>{_self.state.loading=false;_self.scope.$apply();});},getAvailableLandTax:(callback)=>{if(!_self.state.loggedIn)return;_self.state.loading=true;_self.ajax.call(`/api/finebruh/landtax`,"GET",true,{},(data)=>{_self.state.loading=false;callback?callback(data):null;},(data)=>{_self.state.loading=false;_self.scope.$apply();});},claimLandTax:(groupid,callback)=>{if(!_self.state.loggedIn)return;_self.state.loading=true;_self.ajax.call(`/api/finebruh/landtax/`+groupid,"POST",true,{},(data)=>{_self.state.loading=false;callback?callback(data):null;},(data)=>{_self.state.loading=false;_self.scope.$apply();});},cutdownTree:(x,y,callback)=>{_self.ajax.call(`/api/land/cutdown/${x}/${y}`,"PUT",true,{},(data)=>{callback?callback(data):null;});},clearPreparedLands:()=>{if(!_self.state.loggedIn){return;} if(!_self.state.landPrepared)return;_self.state.landPrepared=null;_self.ajax.call("/api/land","DELETE",true,null);},setLand360Url:(land)=>{if(!confirm("You are about to change virtual 360 room url connected to this virtual land. When other users click the view button from the marketplace, they will have an option to visit your virtual room instead of the map. Make sure your virtual 360 room is not expired or deleted. Setting the url to blank will remove this functionality from your land. Please confirm to continue."))return;let url=prompt("Enter a 360 property url found on 360.vpark.io account page.");_self.ajax.call("/api/land/"+land.group_id+"/360/url","PUT",true,{property_url:url},(data)=>{_self.state.user.lands.find(e=>e.group_id==land.group_id).property_url=url;_self.scope.$apply();});},setGroupLeasePrice:(group_id,callback)=>{let price=parseFloat(prompt("Enter a valid vDiamonds you want to charge for rent @ 30 days. You can set the price to 0 to disable future lease."));if(isNaN(price)||(price>0&&price<1)){alert("Invalid price");return;} let g=_self.state.user.lands.find(e=>e.group_id==group_id);if(g.lease_price==price){return;} if(g.lease_price==0) if(prompt("I understand there is a 5% commission fee per lease. You won't be able to build or extend subscription on lands you lease. Please type \"AGREE\" to continue.")!="AGREE")return;_self.ajax.call("/api/land/"+group_id+"/rent/price","PUT",true,{price:price},(data)=>{_self.state.user.lands.find(e=>e.group_id==group_id).lease_price=price;_self.scope.$apply();});},setGroupPrice:(group_id)=>{let price=prompt("Enter a valid total rounded price in USD you want to sell these squares for. The amount for listing should be at least $1. You can set the price to $0 to remove your land from listing.");if(price.length<1)return;if(isNaN(price)||(price>0&&price<1)){alert("Invalid price");return;} let g=_self.state.user.lands.find(e=>e.group_id==group_id);if(g.listed==price){return;} if(g.listed==0) if(prompt("I understand that there "+(g.stamped?"are fees up to 15% for stamped land":"is a 5% commission fee")+" vPark will take from the listed price. I agree that my listing may be cached on multiple servers, and changes may not immediately occur. I understand that any purchases made between my changes are valid and final and that vPark will use the previous state for the transaction. Please type \"AGREE\" to continue.")!="AGREE")return;_self.ajax.call("/api/land/"+group_id+"/price","PUT",true,{price:price},(data)=>{_self.state.user.lands.find(e=>e.group_id==group_id).listed=price;_self.scope.$apply();});},stampGroup:(group_id)=>{if(!confirm("Do you want to stamp this virtual land?"))return;_self.ajax.call("/api/land/"+group_id+"/stamp","POST",true,null,(data)=>{if(prompt("IMPORTANT NOTICE.\nBy stamping this land, you will earn royalties whenever your land is resold where you are neither the buyer nor seller. You will earn 9% royalties for each sale in our 360 properties, or 5% when traded in the marketplace. You will get more royalties in 360 properties since this is a premium feature. vPark's commission fee is 5% for 360 properties and 10% for the marketplace. Stamping land does not give you any privileges or rights to dictate our company's direction or services limitations. If you plan to resell the land from a 360 room, please try building a virtual property from 360.vpark.io to make sure your computer and browser meet the minimum requirement to enter it. You accept the product as-is. Please type \"AGREE\" in capital letters to confirm you accept this. This action is 100% final, nonrefundable, indisputable, and irreversible.")!="AGREE"){return;} _self.ajax.call("/api/land/"+group_id+"/stamp","PUT",true,null,(data)=>{alert("Congrats! You have stamped your land. You can now display it under Virtual Properties.");});});},loadGroupsOnSale:(x1,y1,x2,y2)=>{if(!_self.loggedIn)return;if(!x1)[x1,y1,x2,y2]=_self.scope.getMapBound();if(_self.scope.lastRandomLandCoords[0]==x1&&_self.scope.lastRandomLandCoords[1]==y1&&_self.scope.lastRandomLandCoords[2]==x2&&_self.scope.lastRandomLandCoords[3]==y2)return;_self.scope.lastRandomLandCoords=[x1,y1,x2,y2];_self.ajax.call(`/api/land/available/${x1}/${y1}/${x2}/${y2}`,"GET",true,null,(data)=>{_self.state.landsOnSaleOnMap=data;if(_self.state.current&&_self.state.current.path=='map/land')_self.state.current.data=data;_self.scope.$apply();});},setGroupOffer:(group_id,idx)=>{let price=prompt("Enter a valid total rounded price in USD you want to sell these squares for. A bid should be at least $1. You can set the offer to $0 to remove your bid. Any changes you made will remove the acceptance or state of your previous offer. User can see your offer for 30 days.");if(!price||price.length<1)return;if(isNaN(price)||(price>0&&price<1)){alert("Invalid price");return;} _self.ajax.call("/api/land/"+group_id+"/offer","POST",true,{price:price},(data)=>{if(idx){let l=_self.state.purchasableLands.listed[idx];if(l&&l.group_id==group_id)l.my_offer=data.price;} _self.scope.$apply();});},deleteGroupOffer:(group,idx)=>{if(!confirm("Please confirm you want to delete this bid."))return;_self.ajax.call("/api/land/"+group.group_id+"/offer/"+group.offer_details[idx].hash,"DELETE",true,null,(data)=>{group.offers-=1;group.offer_details.splice(idx,1);_self.scope.$apply();});},acceptGroupOffer:(group,idx)=>{if(!group.listed){alert("You must first list your property on the market before accepting a bid.");return;} if(!confirm("Are you sure you want to let this user buy your property for $"+group.offer_details[idx].price+"?"))return;_self.ajax.call("/api/land/"+group.group_id+"/offer/"+group.offer_details[idx].hash,"PUT",true,null,(data)=>{group.offer_details[idx].accepted=1;_self.scope.$apply();alert("You've accepted a bid, the bidder can now complete the purchase with the new price.");});},loadGroupOffer:(group)=>{_self.ajax.call("/api/land/"+group.group_id+"/offers","GET",true,null,(data)=>{group.offer_details=data;_self.scope.$apply();});},loadMarket:(sort,offset,callback)=>{if(!_self.state.loggedIn)return;if(_self.state.purchasableLands){offset=Math.min(Math.floor(offset / _self.state.purchasableLands.limit)*_self.state.purchasableLands.limit,Math.floor((_self.state.purchasableLands.available-1)/ _self.state.purchasableLands.limit)*_self.state.purchasableLands.limit);offset=Math.max(offset,0);if(offset==_self.state.purchasableLands.offset&&_self.state.marketSort==_self.state.lastMarketSort&&_self.state.marketCountry==_self.state.lastMarketCountry&&_self.state.marketMaxPrice==_self.state.lastMarketMaxPrice&&_self.state.marketMinPrice==_self.state.lastMarketMinPrice&&_self.state.marketCountry==_self.state.lastMarketCountry&&_self.state.marketOffer==_self.state.lastMarketOffer&&_self.state.marketSearch==_self.state.lastMarketSearch&&_self.state.lastMarketAsc==_self.state.marketAsc){callback?callback():null;return;}} _self.state.lastMarketSort=sort;_self.state.lastMarketCountry=_self.state.marketCountry;_self.state.lastMarketOffer=_self.state.marketOffer;_self.state.lastMarketMaxPrice=_self.state.marketMaxPrice;_self.state.lastMarketMinPrice=_self.state.marketMinPrice;_self.state.lastMarketAsc=_self.state.marketAsc;_self.state.lastMarketSearch=_self.state.marketSearch;var query="?";if(_self.state.marketOffer)query+="offer=1";if(_self.state.marketMaxPrice&&parseFloat(_self.state.marketMaxPrice)>0)query+="&max_sqr_price="+_self.state.marketMaxPrice;if(_self.state.marketMinPrice&&parseFloat(_self.state.marketMinPrice)>0)query+="&min_sqr_price="+_self.state.marketMinPrice;if(_self.state.marketAsc)query+="&sort_asc=asc";if(_self.state.marketSearch)query+="&search="+encodeURIComponent(_self.state.marketSearch);let url="/api/land/available/"+_self.state.marketCountry+"/"+sort+"/"+offset+query;_self.urls.loadMarket=url;_self.ajax.call(_self.urls.loadMarket,"GET",true,null,(data)=>{if(_self.urls.loadMarket!=url)return;data.offset=parseInt(data.offset);data.available=parseInt(data.available);data.limit=parseInt(data.limit);_self.state.purchasableLands=data;callback?callback():null;_self.scope.$apply();});},},economy:{landtoken:{search:"",start:(land)=>{if(land.fund)return;var s=_self.state.landToken.newTokenAmount;if(!s||s=='')s=prompt("Enter desired tokens for this investment (we recommend 1T - 20T for start). Your property will be open for token raising for 30 days, failure to complete the token gathering will result in this fund being cancelled.");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid token input");return;} s=parseInt(s);if(s<1){alert("Invalid token input");return;} _self.ajax.call(`/api/land/${land.group_id}/investment`,"POST",true,{tokens:s,purpose:_self.state.landToken.newTokenPurpose,type:_self.state.landToken.newTokenType,duration:_self.state.landToken.newTokenDuration},(data)=>{land.fund=data;land.fundStatus="open";_self.scope.$apply();});},list:(offset=0,callback)=>{_self.ajax.call(`/api/land/open/investments?offset=${offset}&search=${_self.api.economy.landtoken.search}`,"GET",true,null,(data)=>{_self.state.landfunds.offset=parseInt(data.offset);_self.state.landfunds.available=parseInt(data.total);_self.state.landfunds.limit=parseInt(data.limit);_self.state.investableLands=data.investments;_self.scope.$apply();callback?callback():0;});},mine:(offset=0,callback)=>{_self.ajax.call(`/api/land/me/investments`,"GET",true,null,(data)=>{_self.state.myInvestedLands=data;_self.scope.$apply();callback?callback():0;});},get:(group_id,callback)=>{_self.ajax.call(`/api/land/${group_id}/investment`,"GET",true,null,(data)=>{callback?callback(data):0;});},getSimple:(group_id,callback)=>{_self.ajax.call(`/api/land/${group_id}/investment/latest/simple`,"GET",true,null,(data)=>{callback?callback(data):0;});},cancel:(land)=>{if(!land.fund)return;if(!confirm("This action is non-cancellable, all tokens will return to the original owners."))return;_self.ajax.call(`/api/land/${land.group_id}/investment`,"DELETE",true,null,(data)=>{land.fund=null;land.fundStatus=null;_self.scope.$apply();});},shop:(land)=>{if(!_self.state.loggedIn)return;_self.api.economy.content.list(land);_self.api.economy.content.ofLand(land);_self.state.shopInvestmentLand=land;},invest:(landfund)=>{if(!_self.state.loggedIn)return;var s=_self.state.landfunds.investingAmount;if(!s||s=='')s=prompt("How many tokens will you put here? This action is final and non-cancellable.");else if(!confirm("This action is non-cancellable, proceed?"))return;if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid token input");return;} s=parseInt(s);if(s<1){alert("Invalid token input");return;} _self.ajax.call(`/api/land/${landfund.group_id}/investment/join`,"POST",true,{tokens:s},(data)=>{landfund.invested=(landfund.invested?landfund.invested:0)+s;alert("You've successfully invest in this land.") _self.scope.$apply();});},},content:{search:'',create:(callback)=>{if(!_self.state.loggedIn)return;if(_self.state.terranews.newContent.tokens<0||_self.state.terranews.newContent.tokens>10000)return;if(_self.state.terranews.newContent.title.length<5)return;if(_self.state.terranews.newContent.content.length<5&&!_self.state.terranews.newContent.file)return;var formData=new FormData();let input=$('#tn_content_file')[0];if(input.files[0])formData.append('file',input.files[0]);formData.append('price',_self.state.terranews.newContent.tokens);formData.append('title',_self.state.terranews.newContent.title);formData.append('content',_self.state.terranews.newContent.content);formData.append('digicard',_self.state.terranews.newContent.digicard?_self.state.terranews.newContent.digicard:null);$.ajax({url:`/api/terranews/contents`,headers:{Authorization:_self.bearer,},method:"POST",data:formData,processData:false,contentType:false,success:function(data,textStatus,xhr){_self.state.terranews.newContent={tokens:1};$('#tn_content_file')[0].value='';_self.state.mycontent.submitted=true;_self.state.user.contents=data;_self.scope.$apply();callback?callback():null;},error:function(data){alert(data.responseJSON.message);}});},delete:(content,callback)=>{if(!_self.state.loggedIn)return;if(!confirm("This action is final, this content will be permanently deleted."))return;_self.ajax.call(`/api/terranews/contents/${content.id}`,"DELETE",true,null,(data)=>{_self.state.user.contents=data;_self.scope.$apply();callback?callback():0;});},setPrice:(content,callback)=>{if(!_self.state.loggedIn||!content)return;var s=prompt("How many tokens do you want to sell this for? This action is final and non-cancellable.");if(!confirm("This action is non-cancellable, proceed?"))return;if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid token input");return;} s=parseInt(s);if(s<1){alert("Invalid token input");return;} _self.ajax.call(`/api/terranews/contents/${content.id}/price`,"PUT",true,{price:s},(data)=>{content.price=s;_self.scope.$apply();callback?callback():0;});},buy:(land,content,callback)=>{if(!_self.state.loggedIn||!land||!content)return;if(!confirm("This action is non-cancellable, the remaining tokens on your invested land will be spent to purchase this content."+(content.bidded&&!content.bidded_accepted?"There is a pending negotiation, this purchase will use the original token price set by the content creator.":"")))return;_self.ajax.call(`/api/terranews/contents/${content.id}/purchase`,"POST",true,{group_id:land.group_id},(data)=>{_self.scope.$apply();alert("Purchase successful. If this caption contains a purchasable NFT, it is automatically set to 2x the minimum price. To change the listing price, visit your account -> properties -> select land -> investment page. Thank you for supporting this business.");callback?callback():0;});},list:(land,offset=0,limit=20,callback)=>{if(!_self.state.loggedIn)return;_self.ajax.call(`/api/terranews/contents/purchasable/${land && land.fund? land.fund.id : null}?search=${_self.api.economy.content.search}&limit=${limit}&offset=${offset}`,"GET",true,null,(data)=>{_self.state.purchasableContents=data.data;_self.state.db.content=data;_self.scope.$apply();callback?callback():0;});},ofLand:(land,offset=0,limit=20,callback)=>{if(!_self.state.loggedIn)return;_self.state.purchasedContents=[];_self.ajax.call(`/api/terranews/contents/purchased/${land.group_id}?search=${_self.api.economy.content.search}&limit=${limit}&offset=${offset}`,"GET",true,null,(data)=>{_self.state.purchasedContents=data.data;_self.state.db.purchasedContent=data;_self.scope.$apply();callback?callback():0;});},ofInvestment:(investment,offset=0,limit=20,callback)=>{if(!_self.state.loggedIn)return;_self.state.db.investedContent=[];_self.ajax.call(`/api/terranews/contents/invested/${investment.id}?search=${_self.api.economy.content.search}&limit=${limit}&offset=${offset}`,"GET",true,null,(data)=>{_self.state.db.investedContent=data;_self.scope.$apply();callback?callback():0;});},loadBids:(content)=>{if(!_self.state.loggedIn||!content)return;_self.ajax.call(`/api/terranews/contents/${content.id}/bids`,"GET",true,null,(data)=>{content.bids=data;_self.scope.$apply();});},digicard:{setPrice:(content)=>{if(!_self.state.loggedIn||!content||!content.digicard)return;var s=prompt(`Enter desired price to sell this Digicard. $${content.digicard_min_price} (pre-fee) of sales will be given to the Digicard seller and ${content.digicard_royalty*100+2.5}% of the remaining will be deducted as vPark fee and royalty to the original artist. The rest will be distributed to you, your token investors, and the creator of this content. You can enter 0 to hide the content from TerraNews.`);if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid price input");return;} s=parseInt(s);if(s!=0&&s{content.digicard_price=s;_self.scope.$apply();});},buy:(content)=>{if(!_self.state.loggedIn||!content)return;if(content.attachment&&!confirm("This content contains a meme, please be mindful that you are purchasing the DigiCard with NFT, not the Meme."))return;if(!confirm("This action is final, in order to resell this asset, you must list them through vPark Land investment."))return;_self.ajax.call(`/api/digicard/card/${content.digicard}/content/${content.id}/buy`,"POST",true,null,(data)=>{alert("Congrats!");});},},approveBid:(content,bid)=>{if(!_self.state.loggedIn||!content)return;_self.ajax.call(`/api/terranews/contents/${content.id}/bid/${bid.investment_id}/approve`,"POST",true,null,(data)=>{bid.accepted=true;_self.scope.$apply();});},counterBid:(content,bid)=>{if(!_self.state.loggedIn||!bid||!content)return;var s=prompt("Enter desired tokens to counter this presented price.");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid token input");return;} s=parseInt(s);if(s<0){alert("Invalid token input");return;} _self.ajax.call(`/api/terranews/contents/${content.id}/bid/${bid.investment_id}`,"POST",true,null,(data)=>{content.bidded=s;_self.scope.$apply();alert("New price request submitted.");});},rejectBid:(content,bid)=>{if(!_self.state.loggedIn||!content)return;_self.ajax.call(`/api/terranews/contents/${content.id}/bid/${bid.investment_id}/reject`,"POST",true,null,(data)=>{content.bids=content.bids.filter(function(el){return el.id!=bid.id;});content.offers--;_self.scope.$apply();});},negotiate:(land,content)=>{if(!_self.state.loggedIn||!land||!content)return;var s=prompt("Enter desired tokens for this purchase (1 token minimum).");if(!s||s=='')return;if(!s||isNaN(s)||!Number.isInteger(parseInt(s))){alert("Invalid token input");return;} s=parseInt(s);if(s<1){alert("Invalid token input");return;} _self.ajax.call(`/api/terranews/contents/${content.id}/bid/${land.fund.id}`,"POST",true,{price:s},(data)=>{content.bidded=s;_self.scope.$apply();alert("New price request submitted.");});},}},terranews:{loadPollResult:(content)=>{if(!_self.state.loggedIn)return;_self.ajax.call("/api/terranews/contents/"+content.id+"/polls","GET",true,null,(data)=>{for(var i in content.polls){let p=content.polls[i];for(var x in data){let r=data[x];if(r.id==p.id){content.hasAnswers=r.response!=null;p.response=r.response;p.results=r.results;p.answer=p.response?p.response.option_id:null;}}} _self.scope.$apply();});},loadWaitlist:()=>{if(!_self.loggedIn)return;_self.ajax.call("/api/terratalk/waitlist/terratalk","GET",true,{},(data)=>{_self.state.terranews['waitlist']=data;_self.scope.$apply();});},joinWaitlist:()=>{_self.ajax.call("/api/terratalk/waitlist/terratalk","POST",true,{},(data)=>{_self.api.terranews.loadWaitlist();_self.scope.$apply();});},loadMyContent:(callback)=>{_self.ajax.call("/api/terranews/contents/mine","GET",true,{},(data)=>{_self.state.user.contents=data;_self.scope.$apply();callback?callback():0;});},loadContents:(x1,y1,x2,y2)=>{_self.ajax.call(`/api/terranews/contents/${x1}/${y1}/${x2}/${y2}?offset=0`,"GET",true,{},(data)=>{_self.state.terranews['contents']=data;if(_self.state.current&&_self.state.current.path=='map/news')_self.state.current.data=data;var q=true;for(var i in data)if(data[i].type==2){_self.api.terranews.loadPollResult(data[i]);q=false;} if(q)_self.scope.$apply();});},loadDigicards:(x1,y1,x2,y2)=>{_self.ajax.call(`/api/terranews/digicards/${x1}/${y1}/${x2}/${y2}?offset=0`,"GET",true,{},(data)=>{_self.state.terranews['digicards']=data;if(_self.state.current&&_self.state.current.path=='map/digicard')_self.state.current.data=data;});},loadAds:(x1,y1,x2,y2)=>{_self.ajax.call(`/api/terranews/ads/${x1}/${y1}/${x2}/${y2}?offset=0`,"GET",true,{},(data)=>{_self.state.terranews['ads']=data;_self.scope.$apply();});_self.api.terranews.loadScans(x1,y1,x2,y2);},loadingScans:false,loadScans:(x1,y1,x2,y2)=>{if(_self.api.terranews.loadingScans)return;_self.api.terranews.loadingScans=true;_self.ajax.call(`/api/terranews/scans/${x1}/${y1}/${x2}/${y2}?offset=0`,"GET",true,{},(data)=>{_self.state.terranews['scans']=data.scans;_self.api.terranews.loadingScans=false;_self.scope.$apply();},()=>{_self.api.terranews.loadingScans=false;});},likeContent:(content,upvote)=>{_self.ajax.call(`/api/terranews/contents/${content.id}/vote/${upvote}`,"POST",true,{},(data)=>{content.likes=data;_self.scope.$apply();});},pollSubmit:(content)=>{if(!_self.state.loggedIn)return;var answers={};for(var i in content.polls){if(!content.polls[i].answer)return;answers[content.polls[i].id]=content.polls[i].answer==0?content.polls[i].new_answer:content.polls[i].answer;if(!answers[content.polls[i].id]||answers[content.polls[i].id]=='')return;} _self.ajax.call("/api/terranews/contents/"+content.id+"/polls","POST",true,answers,(data)=>{_self.api.terranews.loadPollResult(content);_self.scope.$apply();});},},landchat:{loadUnread:()=>{if(!_self.loggedIn)return;_self.ajax.call("/api/landchat/unread","GET",true,{},(data)=>{_self.state.landchats.unread=data.unread;});},loadStatus:(group_code,v)=>{if(!_self.loggedIn)return;_self.ajax.call("/api/landchat/waitlist/general","GET",true,{},(data)=>{_self.state.landchats[group_code]=data;_self.api.landchat.loadContents(group_code,0);});},loadContents:(group_code,thread)=>{if(!_self.state.loggedIn)return;_self.api.landchat.loadUnread();let preQ=_self.state.landchats["contents"]?_self.state.landchats["contents"].length:0;_self.ajax.call("/api/landchat/contents/"+group_code+"/"+thread,"GET",true,{},(data)=>{if(_self.state.landchatGroup!=group_code)return;_self.state.landchats["contents"]=data.length?data:null;_self.scope.$apply();if(data&&preQ!=data.length){setTimeout(()=>{_self.scope.LCScrollDown();},1000);}},(e)=>{_self.state.landchats["contents"]=null;_self.state.showLandchat=false;_self.scope.$apply();});},postContents:(group_code,thread,content)=>{if(!_self.state.loggedIn)return;if(!content||content.length<1)return;_self.ajax.call("/api/landchat/contents/"+group_code+"/"+thread,"POST",true,{content:content,thread:thread,group_code:group_code,},(data)=>{data.hash=_self.state.user.hash;data.name=_self.state.user.name;_self.state.landchats["contents"].unshift(data);_self.state.landchatNewContent="";_self.scope.$apply();_self.scope.LCScrollDown();});},joinWaitlist:(group_code)=>{if(!_self.state.loggedIn)return;if(_self.state.user.voting_powers[group_code]==0){alert("More square ownership is needed to join this chat");return;} _self.ajax.call("/api/landchat/waitlist/general","POST",true,{},(data)=>{_self.api.landchat.loadStatus(group_code);_self.scope.$apply();});},},v360:{db:{},createRoom:(room_hash,callback)=>{if(!_self.loggedIn)return;if(_self.api.v360.creating)return;_self.api.v360.creating=true;_self.ajax.call("/api/360/rooms/"+room_hash,"POST",true,{},(data)=>{_self.api.v360.db[room_hash]=data;_self.api.v360.creating=false;callback?callback():0;},()=>{_self.api.v360.creating=false;});},getRoom:(room_hash,callback)=>{if(!_self.loggedIn)return;_self.ajax.call("/api/360/rooms/"+room_hash,"GET",true,{},(data)=>{_self.api.v360.db[room_hash]=data;callback?callback():0;});},},store:{db:{},create:(callback)=>{if(!_self.loggedIn)return;if(_self.api.store.creating)return;_self.api.store.creating=true;_self.ajax.call(`/api/commerce/stores`,"POST",true,{},(data)=>{_self.api.store.creating=false;callback?callback(data):0;},()=>{_self.api.store.creating=false;});},getStores:(callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/commerce/stores`,"GET",true,{},(data)=>{callback?callback(data):0;},()=>{});},getStore:(store_hash,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/commerce/stores/${store_hash}`,"GET",true,{},(data)=>{callback?callback(data):0;},()=>{});},save:(store,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/commerce/stores/${store.hash}`,"PUT",true,store,(data)=>{callback?callback(data):0;},()=>{});},addProduct:(store,callback)=>{if(!_self.loggedIn)return;if(_self.api.store.creating)return;_self.api.store.creating=true;_self.ajax.call(`/api/commerce/stores/${store.hash}/products`,"POST",true,{},(data)=>{_self.api.store.creating=false;callback?callback(data):0;},()=>{_self.api.store.creating=false;});},getProducts:(store,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/commerce/stores/${store.hash}/products`,"GET",true,{},(data)=>{callback?callback(data):0;},()=>{});},getProduct:(product_hash,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/commerce/products/${product_hash}`,"GET",true,{},(data)=>{callback?callback(data):0;},()=>{});},deleteProduct:(product_hash,callback)=>{},saveProduct:(product,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/commerce/products/${product_hash}`,"PUT",true,product,(data)=>{callback?callback(data):0;},()=>{});},},property:{db:{},get:(property_hash,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/properties/${property_hash}/detail`,"GET",true,{},(data)=>{callback?callback(data):0;},()=>{});},getSetting:(property_hash,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/properties/${property_hash}/setting`,"GET",true,{},(data)=>{callback?callback(data):0;},()=>{});},update:(property,callback)=>{if(!_self.loggedIn)return;_self.ajax.call(`/api/properties/${property.hash}`,"PUT",true,{},(data)=>{callback?callback(data):0;},()=>{});},item:{db:{},update:(property_hash,item,callback)=>{if(!_self.loggedIn)return;if(_self.api.property.item.creating)return;_self.api.property.item.creating=true;_self.ajax.call(`/api/properties/${property_hash}/items/${item.id}`,"PUT",true,item,(data)=>{_self.api.property.item.creating=false;callback?callback(data):0;},()=>{_self.api.property.item.creating=false;});},},},landsquare:{db:{},createRoom:(sqr,group_id,x,y,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;if(!confirm("You are about to build a vPARK 360 Room (360.vpark.io) on this land square. The property will have 360 surrounding the environment, You can only change the 360 background to default 360s on vpark or to those taken around you land location and uploaded to vPARK by other users. I understand that it also costs money to build and demolish a property associated to each land square. This action is final."))return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/${group_id}/square/${x}/${y}/build/360room`,"POST",true,{},(data)=>{sqr.property=data.property_hash;sqr.type=data.type;_self.api.landsquare.creating=false;alert("Building property successful.");callback?callback():0;},()=>{_self.api.landsquare.creating=false;});},build:(x,y,project,month,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build`,"POST",true,{project:project,unit:month},(data)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat="Building property successful.";_self.state.selectedToBuild=null;let sqr=_self.state.selectedREToBuild;sqr.type=data.type;sqr.address=data.hash;sqr.re_type=data.type;sqr.builder=_self.state.user.hash;_self.state.selectedREToBuild=null;callback?callback(data):0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},renew:(hash,month,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/properties/${hash}/renew`,"POST",true,{unit:month},(data)=>{_self.api.landsquare.creating=false;callback?callback(data):0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createStreetLight:(x,y,str,val,url,scale,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/streetlight`,"POST",true,{text:str,value:val,scale:scale,url:url},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},rotateRing:(hash,address,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/properties/${hash}/ring/face`,"PUT",true,{address:address},(data)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat="Building modification successful.";callback?callback(data):0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},setRingInteraction:(hash,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/properties/${hash}/ring/interaction`,"PUT",true,null,(data)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat="Building modification successful.";callback?callback(data):0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},setTeleport:(hash,address,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/properties/${hash}/teleport/destination`,"PUT",true,null,(data)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat="Building modification successful.";callback?callback(data):0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},setTalkshow:(hash,address,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/properties/${hash}/theater/playlist`,"PUT",true,{address:address},(data)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat="Building modification successful.";callback?callback(data):0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createRing:(x,y,str,val,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/ring`,"POST",true,{text:str,value:val},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createBrainStation:(x,y,str,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/brain`,"POST",true,{text:str},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createHouse:(x,y,str,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/house`,"POST",true,{text:str},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createSmallHouse:(x,y,str,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/smallhouse`,"POST",true,{text:str},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createRestaurant:(x,y,str,builder,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/restaurant`,"POST",true,{text:str,builder:builder},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createTower:(x,y,str,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/tower`,"POST",true,{text:str},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},create360Theater:(x,y,str,url,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/360theater`,"POST",true,{text:str,url:url},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createCommerceBuilding:(x,y,str,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/commerce`,"POST",true,{text:str},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');_self.api.landsquare.db.stat="Building property successful.";callback?callback():0;},(err)=>{_self.api.landsquare.creating=false;_self.api.landsquare.db.stat=err;});},createCustomProperty:(x,y,type,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/produce`,"POST",true,{type:type},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');alert("Building property successful.");callback?callback():0;},()=>{_self.api.landsquare.creating=false;});},createTeleport:(x,y,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/any/square/${x}/${y}/build/teleport`,"POST",true,{},(data)=>{_self.api.landsquare.creating=false;ue4('reloadRealEstates');ue4('closeWindow');alert("Building property successful.");callback?callback():0;},()=>{_self.api.landsquare.creating=false;});},createGallery:(sqr,group_id,x,y,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;if(!confirm("You are about to build a HD Gallery (still on development but open for presale) on this land square. The property will have 360 surrounding the environment, if there is no 360 taken around your land you cannot set what 360 your viewers will see. The 360s will either be dynamic or static. I understand that it also costs money to build and demolish a property associated to each land square. This action is final."))return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/${group_id}/square/${x}/${y}/build/gallery`,"POST",true,{},(data)=>{sqr.property=data.property_hash;sqr.type=data.type;_self.api.landsquare.creating=false;alert("Building property successful.");callback?callback():0;},()=>{_self.api.landsquare.creating=false;});},create360Island:(sqr,group_id,x,y,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.creating)return;if(!confirm("You are about to build a 360 Island (still on development but open for presale) on this land square. To create a 360 land, you need to provide or reuse other's 360 videos. Your 360s on AWS or other hosting services, or contact us if you want us to host your media. I understand that it also costs money to build and demolish a property associated to each land square. This action is final."))return;_self.api.landsquare.creating=true;_self.ajax.call(`/api/land/${group_id}/square/${x}/${y}/build/360island`,"POST",true,{},(data)=>{sqr.property=data.property_hash;sqr.type=data.type;_self.api.landsquare.creating=false;alert("Building property successful.");callback?callback():0;},()=>{_self.api.landsquare.creating=false;});},destroyProperty:(sqr,callback)=>{if(!_self.loggedIn)return;if(_self.api.landsquare.deleting)return;if(!confirm("Demolishing this property costs $5 per square. This action is final and non-refundable. You will lose access to the property you built."))return;_self.api.landsquare.deleting=true;_self.ajax.call(`/api/properties/${sqr.coord.property}/demolish`,"DELETE",true,{},(data)=>{sqr.property=null;sqr.coord.property=null;sqr.coord.type=0;_self.api.landsquare.deleting=false;alert("Demolishing property successful.");callback?callback():0;},()=>{_self.api.landsquare.deleting=false;});},},}} return _self;});URL=window.URL||window.webkitURL;var AudioContext=window.AudioContext||window.webkitAudioContext;var isOpera=(!!window.opr&&!!opr.addons)||!!window.opera||navigator.userAgent.indexOf(' OPR/')>=0;var isFirefox=typeof InstallTrigger!=='undefined';var isSafari=/constructor/i.test(window.HTMLElement)||(function(p){return p.toString()==="[object SafariRemoteNotification]";})(!window['safari']||(typeof safari!=='undefined'&&safari.pushNotification));var isIE=/*@cc_on!@*/ false||!!document.documentMode;var isEdge=!isIE&&!!window.StyleMedia;var isChrome=!!window.chrome&&(!!window.chrome.webstore||!!window.chrome.runtime);var isBlink=(isChrome||isOpera)&&!!window.CSS;const zeroPad=(num,places)=>String(num).padStart(places,'0');Object.fromEntries=(o)=>{var r={};for(var i in o)r[o[i][0]]=o[i][1];return r;};var html=$("html").get()[0];const initZoom=3;const defaultZoom=17;const newsZoom=13;const cityZoom=8;const defaultContentZoom=17;let lon_span=360;let lat_span=180;let circum=40075000;let tile_s=2500000;let tile_w=circum / tile_s;String.prototype.double=()=>parseFloat(self);function stripHtml(html){let tmp=document.createElement("DIV");tmp.innerHTML=html;return tmp.textContent||tmp.innerText||"";} var dc_checkStatus=false;var dc_element=new Image();var dc_banned=false;Object.defineProperty(dc_element,'id',{get:function(){dc_checkStatus=true;throw new Error("Dev tools checker");}});window.appScope=null;app.config(function($locationProvider){$locationProvider.html5Mode(true);});app.filter('unsafe',['$sce',function($sce){return function(text){return $sce.trustAsHtml(text);};}]);app.directive('onErrorSrc',function(){return{link:function(scope,element,attrs){element.bind('error',function(){if(attrs.src!=attrs.onErrorSrc){attrs.$set('src',attrs.onErrorSrc);}});}}}).directive('myEnter',function(){return function(scope,element,attrs){element.bind("keydown keypress",function(event){if(event.which===13){scope.$apply(function(){scope.$eval(attrs.myEnter);});event.preventDefault();}});};}).config(['$compileProvider',function($compileProvider){$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|local|data|chrome-extension):/);}]).controller('c-land',['$scope','$location','vService',function($scope,$location,vService){window.appScope=$scope;$scope.max=function(a,b){return Math.max(a,b);} $scope.filterNotObject=function(dict){let r={};Object.entries(dict).filter(([k,v])=>typeof v!='object'||v==null).map(([k,v])=>r[k]=v);return r;} $scope.filterObject=function(dict){let r={};Object.entries(dict).filter(([k,v])=>typeof v=='object').map(([k,v])=>r[k]=v);return r;} $scope.sum=function(arr,e){var r=0;for(var i=0;i{$(window).scrollTop(0);};$scope.compactNum=(e)=>Intl.NumberFormat('en',{notation:'compact'}).format(e);$scope.intervals={};$scope.rotateIntInterval=(x,max,interval)=>{if($scope.intervals[x])clearInterval($scope.intervals[x]);$scope.intervals[x]=setInterval(()=>{$scope.rotateInt(x,max);},interval);if(!$scope.state[x])$scope.state[x]=0;} $scope.rotateInt=(x,max)=>{if(!$scope.state[x])$scope.state[x]=0;$scope.state[x]=($scope.state[x]+1)%max;} $scope.rotateSelection=(_var,data)=>{setInterval(()=>{let k=Object.keys(data);let i=(k.indexOf($scope.state[_var])+1)%k.length;$scope.state[_var]=k[i];},6000);} let params=$location.search();let path=params.path;let pages=window.pages;if(path)pages=path.split('/');$scope.state={social:{new:{},playlist:{new:'',id:null,hash:null}},social:{new:{},playlist:{new:'',id:null,hash:null}},world:{route:{price:0},compass:{},realestate:{installation:{},editor:{timeout:null},},bio:{},installation:{},bag:{items:[],selectedItem:null,page:0},shop:{quantities:{},selectedItem:null,selectItemJson:(x)=>{$scope.state.world.shop.selectedItem=JSON.parse(x);$scope.state.world.shop.quantity=0;},quantity:0}},diamond:{exchange:{action:null,usd:0,estimate:null}},pages:pages,db:{},mycontent:{},terranews:{},directives:{},voting:{},zoom:initZoom,action:'drag',selectedSquares:[],loggedIn:false,user:{},reloadingSquare:true,verification:'na',content:{zoom:10,radius:"10",selectedSquares:[]}};$scope.vService=vService;vService.init($scope);$(window).scroll(function(e){if($scope.state.showaccountmenu){$scope.state.showaccountmenu=false;}});$scope.mainTimer=setInterval(()=>{let c=$scope.state.mainTimerCounter++;var z=$('#land-price-led').get();if(z.length){var x=$('#land-price-led').scrollLeft()+2;var maxScrollLeft=$('#land-price-led').get(0).scrollWidth-$('#land-price-led').get(0).clientWidth;if(x>maxScrollLeft)x=0;$('#land-price-led').scrollLeft(x);}},100);$scope.initializePage=()=>{if($scope.state.page==""){$scope.loadStats();}} $scope.refresh=(s)=>{location.href="/"+s;} $scope.open=(s)=>{location.href=s;} $scope.$watch("state.page",(newValue,oldValue)=>{if(location.pathname.indexOf("resetPassword")>=0)return;if($scope.state.page=="undefined")$scope.state.page="";if(!$scope.state.page)$scope.state.page="";if($scope.state.page=='howto')$scope.state.page="how-to";if(!$scope.state.pages||typeof $scope.state.pages!='object'||(newValue&&newValue.indexOf("dashboard")!=0)) $scope.state.pages=newValue.split("/");$scope.initializePage() window.history.pushState($scope.state.page,'vPARK','/'+$scope.state.page+($scope.state.page=='landowner'?'/'+url_param_2:''));if(newValue=="dashboard"&&oldValue!="dashboard"&&oldValue&&!$scope.state.pages)window.location.reload();else if(newValue=="dashboard"&&oldValue!="dashboard"&&oldValue)$scope.validate();$scope.scrollTop();});$(window).on('popstate',function(e){if(location.pathname.indexOf("/partners/")==0)window.location.reload();$scope.state.page=location.pathname.substring(1);});$scope.buyLandTick=new Date();$scope.lastRandomLandCoords=[];$scope.state.profileUpdated=true;$scope.savePaypal=()=>{$scope.state.profileUpdated=true;$scope.$apply();} $scope.validate=()=>{$scope.vService.auth.validate(()=>{if($scope.vService.loggedIn) $scope.vService.ajax.call(`/api/user?${location.pathname.indexOf('/dashboard') >= 0 ? "" : "simple=true" }`,"GET",true,null,(data)=>{if(!data.email)return;$scope.state.loggedIn=true;$scope.state.user=data;$scope.$apply();$scope.initializePage()});},()=>{$scope.state.page="dashboard";});} $scope.loadLandowner=(hash)=>{$scope.vService.ajax.call("/api/user/"+hash,"GET",true,null,(data)=>{$scope.state.landowner=data;$scope.$apply();});} $scope.joinMembership=(hash)=>{if(!confirm(`Your one vPARK account works on multiple different land memberships. Confirm you want to join ${subdomain}.`)) return;$scope.vService.ajax.call("/api/join","POST",true,null,(data)=>{$scope.state.user.joined=true;location.assign("/dashboard");});} $scope.validate();$scope.login=(email,password)=>{if(!$scope.state.user.email||$scope.state.user.email.length<6){alert("Please enter a valid email");return;} if(!$scope.state.user.password||$scope.state.user.password.length<8){alert("Password must be at least 8 characters.");return;} grecaptcha.execute('6LcRjFIaAAAAANdjiJ8hATjdcpBVdik9ITN6L8L8',{action:'submit'}).then(function(token){$scope.state.user.capcha=token;$scope.vService.auth.login($scope.state.user,()=>{location.reload();});});} $scope.signout=()=>{$scope.vService.auth.logout(()=>{$scope.state.loggedIn=false;$scope.$apply();location.href="/dashboard";});} $scope.click2FAUrl=()=>{window.open($scope.state.qr.url);} $scope.getKeys=(v)=>{return Object.keys(v);};$scope.loadStats=()=>{$scope.vService.ajax.call("/api/land/stats/countries","GET",false,null,(data)=>{$scope.state.countryStats=data["countries"];$scope.state.userCountryStats=data["user_countries"];$scope.state.big_supporters=data["big_supporters"];$scope.state.gdp=Math.round(data["gdp"]);$scope.state.population=data["population"];$scope.state.crimes=data["crimes"];for(var i in data){data[i].price=parseFloat(data[i].price);}});} const saveCursorPosition=function(x,y){let px=(x / window.innerWidth).toFixed(2)-.5;let py=(y / window.innerHeight).toFixed(2)-.5;let l=Math.sqrt(px*px+py*py);px /=l;py /=l;document.documentElement.style.setProperty('--x',x+'px');document.documentElement.style.setProperty('--y',y+'px');document.documentElement.style.setProperty('--rax',py);document.documentElement.style.setProperty('--ray',-px);let a=(Math.asin(l)/3.14*180);document.documentElement.style.setProperty('--rot',a+'deg');} document.addEventListener('mousemove',e=>{saveCursorPosition(e.clientX,e.clientY);}) saveCursorPosition(0,0);$scope.renderIsSlow=()=>{return window.renderIsSlow>2;};}]);app.controller('c-card-overlay',['$scope','vService',function($scope,vService){$scope.vService=vService;$scope.title="";$scope.showMap=true;$scope.showOverlay='window';$scope.overlayColor='rgba(0,0,0, 0.5)';$scope.overlayWindowColor='rgba(0,0,0, 0.5)';$scope.subpageBackButton=false;$scope.overlayWidth='800px';$scope.$watch('state.dashboard.page',function(newValue,oldValue,scope){$scope.overlayWidth=newValue=='missions'?'calc(100vw - 90px)':'800px';$scope.showOverlay=newValue=='missions'?'atmosphere':'window';$scope.showMap=newValue!='missions';});$scope.click2FAUrl=()=>{window.open($scope.state.qr.url);} $scope.copyToClipboard=function(text){navigator.clipboard.writeText(text).then(function(){},function(err){});} $scope.formatDate=(t)=>{return moment(t).format('MM/DD LT');} $scope.transactionType=(t)=>{let _={"land_tax":"Land Tax","land_sale":"Land","class_residual":"Residual","referral":"Referral","deposit":"Deposit","withdrawal":"Withdraw","refund":"Refund"};return _[t]?_[t]:t;} $scope.range=function(count){if(!count)return[];return[...Array(Math.ceil(count)).keys()];} $scope.nearIndex=(x)=>{return Math.abs(x)<4;};$scope.verifyIdentity=()=>{if($scope.state.page.indexOf("api/world")<0) $scope.vService.ajax.call("/api/profile/verification/id/jumio","POST",true,{},(data)=>{location.href=data;if($scope.refreshVerifyStatusTimer){clearInterval($scope.refreshVerifyStatusTimer);$scope.refreshVerifyStatusTimer=setInterval(()=>{$scope.getVerificationStatus()},5000);}});} $scope.getVerificationStatus=()=>{if(!$scope.vService.loggedIn)return;if($scope.state.page.indexOf("api/world")<0) $scope.vService.ajax.call("/api/profile/verification/id/jumio","GET",true,{},(data)=>{$scope.state.verification=data.status;$scope.state.prev_failure=data.prev_failure;if(data.status=="na"||data.status=="verified"){if($scope.refreshVerifyStatusTimer){clearInterval($scope.refreshVerifyStatusTimer);$scope.refreshVerifyStatusTimer=null;} if(data.status=="failed")location.reload();} $scope.$apply();});} $scope.state.verifyIdentity=$scope.verifyIdentity;$scope.state.getVerificationStatus=$scope.getVerificationStatus;$scope.refreshVerifyStatusTimer=setInterval(()=>{$scope.getVerificationStatus()},5000);$scope.myFilteredProperties=()=>{return $scope.state.user.lands.filter(l=>(!$scope.state.myPropFilters.offers||l.offers>0)&&(!$scope.state.myPropFilters.listed||l.listed>0)&&(!$scope.state.myPropFilters.country||$scope.state.myPropFilters.country==""||l.country==$scope.state.myPropFilters.country));} $scope.ellipsis=function(s,d=70){if(!s)return"";if(s.length>d){return s.substring(0,d)+'...';} return s;} $scope.countryCodeToName=(c)=>{let a={af:"Afghanistan",ax:"Åland Islands",al:"Albania",dz:"Algeria",as:"American Samoa",ad:"Andorra",ao:"Angola",ai:"Anguilla",aq:"Antarctica",ag:"Antigua and Barbuda",ar:"Argentina",am:"Armenia",aw:"Aruba",au:"Australia",at:"Austria",az:"Azerbaijan",bs:"Bahamas",bh:"Bahrain",bd:"Bangladesh",bb:"Barbados",by:"Belarus",be:"Belgium",bz:"Belize",bj:"Benin",bm:"Bermuda",bt:"Bhutan",bo:"Bolivia, Plurinational State of",bq:"Bonaire, Sint Eustatius and Saba",ba:"Bosnia and Herzegovina",bw:"Botswana",bv:"Bouvet Island",br:"Brazil",io:"British Indian Ocean Territory",bn:"Brunei Darussalam",bg:"Bulgaria",bf:"Burkina Faso",bi:"Burundi",kh:"Cambodia",cm:"Cameroon",ca:"Canada",cv:"Cape Verde",ky:"Cayman Islands",cf:"Central African Republic",td:"Chad",cl:"Chile",cn:"China",cx:"Christmas Island",cc:"Cocos (Keeling) Islands",co:"Colombia",km:"Comoros",cg:"Congo",cd:"Congo, the Democratic Republic of the",ck:"Cook Islands",cr:"Costa Rica",ci:"Côte d'Ivoire",hr:"Croatia",cu:"Cuba",cw:"Curaçao",cy:"Cyprus",cz:"Czech Republic",dk:"Denmark",dj:"Djibouti",dm:"Dominica",do:"Dominican Republic",ec:"Ecuador",eg:"Egypt",sv:"El Salvador",gq:"Equatorial Guinea",er:"Eritrea",ee:"Estonia",et:"Ethiopia",fk:"Falkland Islands (Malvinas)",fo:"Faroe Islands",fj:"Fiji",fi:"Finland",fr:"France",gf:"French Guiana",pf:"French Polynesia",tf:"French Southern Territories",ga:"Gabon",gm:"Gambia",ge:"Georgia",de:"Germany",gh:"Ghana",gi:"Gibraltar",gr:"Greece",gl:"Greenland",gd:"Grenada",gp:"Guadeloupe",gu:"Guam",gt:"Guatemala",gg:"Guernsey",gn:"Guinea",gw:"Guinea-Bissau",gy:"Guyana",ht:"Haiti",hm:"Heard Island and McDonald Islands",va:"Holy See (Vatican City State)",hn:"Honduras",hk:"Hong Kong",hu:"Hungary",is:"Iceland",in:"India",id:"Indonesia",ir:"Iran, Islamic Republic of",iq:"Iraq",ie:"Ireland",im:"Isle of Man",il:"Israel",it:"Italy",jm:"Jamaica",jp:"Japan",je:"Jersey",jo:"Jordan",kz:"Kazakhstan",ke:"Kenya",ki:"Kiribati",kp:"Korea, Democratic People's Republic of",kr:"Korea, Republic of",kw:"Kuwait",kg:"Kyrgyzstan",la:"Lao People's Democratic Republic",lv:"Latvia",lb:"Lebanon",ls:"Lesotho",lr:"Liberia",ly:"Libya",li:"Liechtenstein",lt:"Lithuania",lu:"Luxembourg",mo:"Macao",mk:"Macedonia, the former Yugoslav Republic of",mg:"Madagascar",mw:"Malawi",my:"Malaysia",mv:"Maldives",ml:"Mali",mt:"Malta",mh:"Marshall Islands",mq:"Martinique",mr:"Mauritania",mu:"Mauritius",yt:"Mayotte",mx:"Mexico",fm:"Micronesia, Federated States of",md:"Moldova, Republic of",mc:"Monaco",mn:"Mongolia",me:"Montenegro",ms:"Montserrat",ma:"Morocco",mz:"Mozambique",mm:"Myanmar",na:"Namibia",nr:"Nauru",np:"Nepal",nl:"Netherlands",nc:"New Caledonia",nz:"New Zealand",ni:"Nicaragua",ne:"Niger",ng:"Nigeria",nu:"Niue",nf:"Norfolk Island",mp:"Northern Mariana Islands",no:"Norway",om:"Oman",pk:"Pakistan",pw:"Palau",ps:"Palestinian Territory, Occupied",pa:"Panama",pg:"Papua New Guinea",py:"Paraguay",pe:"Peru",ph:"Philippines",pn:"Pitcairn",pl:"Poland",pt:"Portugal",pr:"Puerto Rico",qa:"Qatar",re:"Réunion",ro:"Romania",ru:"Russian Federation",rw:"Rwanda",bl:"Saint Barthélemy",sh:"Saint Helena, Ascension and Tristan da Cunha",kn:"Saint Kitts and Nevis",lc:"Saint Lucia",mf:"Saint Martin (French part)",pm:"Saint Pierre and Miquelon",vc:"Saint Vincent and the Grenadines",ws:"Samoa",sm:"San Marino",st:"Sao Tome and Principe",sa:"Saudi Arabia",sn:"Senegal",rs:"Serbia",sc:"Seychelles",sl:"Sierra Leone",sg:"Singapore",sx:"Sint Maarten (Dutch part)",sk:"Slovakia",si:"Slovenia",sb:"Solomon Islands",so:"Somalia",za:"South Africa",gs:"South Georgia and the South Sandwich Islands",ss:"South Sudan",es:"Spain",lk:"Sri Lanka",sd:"Sudan",sr:"Suriname",sj:"Svalbard and Jan Mayen",sz:"Swaziland",se:"Sweden",ch:"Switzerland",sy:"Syrian Arab Republic",tw:"Taiwan",tj:"Tajikistan",tz:"Tanzania, United Republic of",th:"Thailand",tl:"Timor-Leste",tg:"Togo",tk:"Tokelau",to:"Tonga",tt:"Trinidad and Tobago",tn:"Tunisia",tr:"Turkey",tm:"Turkmenistan",tc:"Turks and Caicos Islands",tv:"Tuvalu",ug:"Uganda",ua:"Ukraine",ae:"United Arab Emirates",gb:"United Kingdom",us:"United States",um:"United States Minor Outlying Islands",uy:"Uruguay",uz:"Uzbekistan",vu:"Vanuatu",ve:"Venezuela, Bolivarian Republic of",vn:"Viet Nam",vg:"Virgin Islands, British",vi:"Virgin Islands, U.S.",wf:"Wallis and Futuna",eh:"Western Sahara",ye:"Yemen",zm:"Zambia",zw:"Zimbabwe",unknown:"Unknown country"};return a[c];} $scope.flagIcon=(c,size='24x18')=>{if(!c)return null;return c=="unknown"?"/images/icons/flag-black.svg":`https://flagcdn.com/${size}/`+c+".png";} $scope.className=(c)=>{c=Math.floor(c);let classes=["Meteor","Rhodium","Platinum","Gold","Ruthenium","Iridium","Osmium","Palladium","Rhenium","Silver","Carbon"] return c-1{return{lat:y / tile_s*lat_span*2-90,lon:x / tile_s*lon_span-180};} $scope.goToCoordInProfileMap=(x,y)=>{let p=$scope.sqr2nw(x,y);profileMap.setCenter([p.lon,p.lat]);} $scope.daysLeft=(t)=>{return moment(t).diff(moment(),"days");}}]).directive('cardOverlay',function(){return{restrict:'E',templateUrl:'pages/metaverse/card_overlay.php',controller:"c-card-overlay",scope:{state:'=',},}}).directive('aLanding',function(){return{restrict:'E',templateUrl:`pages/sub/saas-landing.php?ns=${subdomain}&${Math.random()}`,}}).directive('aHome',function(){return{restrict:'E',templateUrl:'pages/sub/saas-home.php',}}).directive('aContact',function(){return{restrict:'E',templateUrl:'pages/sub/saas-contact.php',}}).directive('bizContact',function(){return{restrict:'E',templateUrl:`pages/sub/business-contact.php?ns=${subdomain}&${Math.random()}`,}}).directive('terms',function(){return{restrict:'E',templateUrl:'pages/sub/terms.php',}}).directive('thirdparty',function(){return{restrict:'E',templateUrl:'pages/sub/3rd-party.php',}}).directive('aFaqs',function(){return{restrict:'E',templateUrl:'pages/sub/faqs.php',}});