implement very simple demo mode
This commit is contained in:
		
							parent
							
								
									6e5cfa9bf2
								
							
						
					
					
						commit
						f0c76c1349
					
				| @ -3,6 +3,8 @@ import { Subscription } from 'rxjs'; | |||||||
| import { MarkBlockState, StateService } from '../../services/state.service'; | import { MarkBlockState, StateService } from '../../services/state.service'; | ||||||
| import { specialBlocks } from '../../app.constants'; | import { specialBlocks } from '../../app.constants'; | ||||||
| import { BlockExtended } from '../../interfaces/node-api.interface'; | import { BlockExtended } from '../../interfaces/node-api.interface'; | ||||||
|  | import { Router } from '@angular/router'; | ||||||
|  | import { sleep$ } from '../../shared/common.utils'; | ||||||
| 
 | 
 | ||||||
| @Component({ | @Component({ | ||||||
|   selector: 'app-start', |   selector: 'app-start', | ||||||
| @ -61,6 +63,7 @@ export class StartComponent implements OnInit, AfterViewChecked, OnDestroy { | |||||||
|   constructor( |   constructor( | ||||||
|     public stateService: StateService, |     public stateService: StateService, | ||||||
|     private cd: ChangeDetectorRef, |     private cd: ChangeDetectorRef, | ||||||
|  |     private router: Router | ||||||
|   ) { |   ) { | ||||||
|     this.isiOS = ['iPhone','iPod','iPad'].includes((navigator as any)?.userAgentData?.platform || navigator.platform); |     this.isiOS = ['iPhone','iPod','iPad'].includes((navigator as any)?.userAgentData?.platform || navigator.platform); | ||||||
|     if (this.stateService.network === '') { |     if (this.stateService.network === '') { | ||||||
| @ -68,7 +71,27 @@ export class StartComponent implements OnInit, AfterViewChecked, OnDestroy { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   async demoMode() { | ||||||
|  |     // @ts-ignore
 | ||||||
|  |     if (!window.demoMode) { | ||||||
|  |       // @ts-ignore
 | ||||||
|  |       window.demoMode = true; | ||||||
|  |       const paths = ['', 'acceleration', 'mining', 'graphs']; | ||||||
|  |       let i = 0; | ||||||
|  |       while ('Bitcoin is still alive') { | ||||||
|  |         i = (i + 1) % paths.length; | ||||||
|  |         this.router.navigateByUrl(paths[i]); | ||||||
|  |         await sleep$(30000); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   ngOnInit() { |   ngOnInit() { | ||||||
|  |     // @ts-ignore
 | ||||||
|  |     if (window.location.search === '?demo=1') { | ||||||
|  |       this.demoMode(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     this.firstPageWidth = 40 + (this.blockWidth * this.dynamicBlocksAmount); |     this.firstPageWidth = 40 + (this.blockWidth * this.dynamicBlocksAmount); | ||||||
|     this.blockCounterSubscription = this.stateService.blocks$.subscribe((blocks) => { |     this.blockCounterSubscription = this.stateService.blocks$.subscribe((blocks) => { | ||||||
|       this.blockCount = blocks.length; |       this.blockCount = blocks.length; | ||||||
|  | |||||||
| @ -226,6 +226,14 @@ export function insecureRandomUUID(): string { | |||||||
|   return uuid.slice(0, -1); |   return uuid.slice(0, -1); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export function sleep$(ms: number): Promise<void> { | ||||||
|  |   return new Promise((resolve) => { | ||||||
|  |      setTimeout(() => { | ||||||
|  |        resolve(); | ||||||
|  |      }, ms); | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // https://stackoverflow.com/a/60467595
 | // https://stackoverflow.com/a/60467595
 | ||||||
| export function md5(inputString): string { | export function md5(inputString): string { | ||||||
|     var hc="0123456789abcdef"; |     var hc="0123456789abcdef"; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user