You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
		
		
		
		
		
			
		
			
				
					
					
						
							105 lines
						
					
					
						
							3.5 KiB
						
					
					
				
			
		
		
	
	
							105 lines
						
					
					
						
							3.5 KiB
						
					
					
				| // Copyright © 2023 Entreprise SkamKraft | |
| 'use strict'; | |
| 
 | |
| import { Timer } from "../skama_code/ui/timer.js"; | |
| import { Modal } from "../skama_code/ui/modal.js"; | |
| import { TemplateEngine } from "../skama_code/ui/templeting_engine.js"; | |
| import { Initialzer } from "../skama_code/commun/initialzer.js "; | |
| import { AgentBuilder } from "../skama_code/api/agent.js"; | |
| import { Auth } from "../skama_code/auth/auth.js"; | |
| import { PlanetBuilder } from "../skama_code/api/planet.js"; | |
| 
 | |
| let temp_path = "html"; | |
| let token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGlmaWVyIjoiSEFSRElDSyIsInZlcnNpb24iOiJ2Mi4xLjQiLCJyZXNldF9kYXRlIjoiMjAyMy0xMi0wMiIsImlhdCI6MTcwMjY2Mjc2Mywic3ViIjoiYWdlbnQtdG9rZW4ifQ.PrvaOz3W79acq6RoxryMW53PRRz824_AM0VGLwfXCOsGCOCAIY-rn6-bZTOnLAtp4xPSDqEk4c38oWYAWW59p0iMDDLpur6ONnjT0RjjsQS9zr5BByfBpP36CT23IZSSzk3XxGrFolHJAyU3K1liYfNbsPuNTXlkHGNHq6yMqH4ZQUPFsXEsCkg9cUynkdLw3C39SvWhtJ89oblj_8tQp2k8dxhZemepuXtiI51eFMpv8A0WRAi7pVYo_ajJujY9QDLYn_m5hDZWTlQMIstjPaDl99p2IMweIMO2Q2G-0lKiWQ4sl6VW5tuVrz1HLYU6kyMjFQWNn6kFDE7LWMTrfw"; | |
| 
 | |
| let tests = { | |
|     timer: function() { | |
|         let timer = new Timer(1, 0.1666, "m"); | |
|         timer.on("step", (time) => { | |
|             console.log(time); | |
|         }) | |
|         timer.on("end", () => { | |
|             console.log("pattes fini"); | |
|         }); | |
|         timer.start(); | |
|     }, | |
|     render_template: function() { | |
|         let UI = new TemplateEngine(temp_path); | |
|         let initer = new Initialzer(UI); | |
| 
 | |
|         UI.render("templates/home.html"); | |
|         UI.frag_load("#test", "templates/login.html"); | |
| 
 | |
|         $(document).ready(() => { | |
|             initer.init_menu_link("#contracts-link", "contracts.html"); | |
|             initer.init_menu_link("#ships-link", "ships.html"); | |
|             initer.init_menu_link("#systems-link", "systems.html"); | |
|             initer.init_menu_link("#signup-link", "register.html"); | |
|             initer.init_menu_link("#signin-link", "login.html"); | |
|             initer.init_menu_link(".nav-brand", "home.html"); | |
|         }); | |
|     }, | |
|     authentication: function() { | |
|         let auth = new Auth(true); | |
|         auth.done((agent) => { | |
|             console.log(agent); | |
|         }).fail((errs) => { | |
|             errs.forEach(err => { | |
|                 console.log(err); | |
|             }); | |
|         }); | |
|         auth.login(token); | |
|         auth.relog(); | |
| 
 | |
|         //auth.register({ | |
|         //    symbol: "lkdsjfsjdlfjlk", | |
|         //    faction: "COSMIC" | |
|         //}); | |
|     }, | |
|     modal: function() { | |
| 
 | |
|         let template_engine = new TemplateEngine(temp_path); | |
|          | |
|         let timer = new Timer(60, 1, "s"); | |
|         timer.on("step", (time) => { | |
|             $("#timer").html(` | |
|                 <p>${time}</p> | |
|             `); | |
|         }); | |
|         template_engine.render("templates/login.html"); | |
| 
 | |
|         let modal = new Modal("test-modal", template_engine); | |
|         modal.add_class("ext-modal") | |
| 
 | |
|         modal.load("templates/test_modal.html"); | |
| 
 | |
|         template_engine.add_event("#valid", "click", () => { | |
|             modal.show(); | |
|             timer.start(); | |
|         }); | |
| 
 | |
|         template_engine.add_event("#ok", "click", () => { | |
|             modal.close(); | |
|             timer.stop(); | |
|         }); | |
|     }, | |
|     get_planet: function() { | |
|         PlanetBuilder.get("X1-TT23-FF1E", (planet) => { | |
|             console.log(planet); | |
|         }, (err) => { | |
|             console.log(err); | |
|         }); | |
|     }, | |
|     get_all_planets: function() { | |
|         PlanetBuilder.list_all("X1-AG10", (planets) => { | |
|             console.log(planets); | |
|         }); | |
|     }, | |
|     get_all_agents: function() { | |
|         AgentBuilder.list_all((agents) => { | |
|             console.log(agents); | |
|         }); | |
|     } | |
| } | |
| 
 | |
| export default tests; |