mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	mobile detection
This commit is contained in:
		
							parent
							
								
									0657815de5
								
							
						
					
					
						commit
						458ed1faff
					
				| @ -9,7 +9,9 @@ const optionService = require('../services/options'); | ||||
| async function index(req, res) { | ||||
|     const options = await optionService.getOptionsMap(); | ||||
| 
 | ||||
|     res.render('index', { | ||||
|     const view = req.cookies['trilium-device'] === 'mobile' ? 'mobile' : 'desktop'; | ||||
| 
 | ||||
|     res.render(view, { | ||||
|         theme: options.theme, | ||||
|         leftPaneMinWidth: parseInt(options.leftPaneMinWidth), | ||||
|         leftPaneWidthPercent: parseInt(options.leftPaneWidthPercent), | ||||
|  | ||||
| @ -42,8 +42,26 @@ | ||||
|     </div> | ||||
| </div> | ||||
| 
 | ||||
| <!-- Required for correct loading of scripts in Electron --> | ||||
| <script>if (typeof module === 'object') {window.module = module; module = undefined;}</script> | ||||
| <script> | ||||
|     // Required for correct loading of scripts in Electron | ||||
|     if (typeof module === 'object') {window.module = module; module = undefined;} | ||||
| 
 | ||||
|     let device = "desktop"; | ||||
| 
 | ||||
|     // mobile device detection based on https://stackoverflow.com/a/24600597/944162 | ||||
|     if (/Mobi/.test(navigator.userAgent) || window.location.search === '?mobile') { | ||||
|         device = "mobile"; | ||||
|     } | ||||
| 
 | ||||
|     setCookie("trilium-device", device); | ||||
| 
 | ||||
|     function setCookie(name, value) { | ||||
|         const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000); | ||||
|         const expires = "; expires=" + date.toUTCString(); | ||||
| 
 | ||||
|         document.cookie = name + "=" + (value || "")  + expires + "; path=/"; | ||||
|     } | ||||
| </script> | ||||
| 
 | ||||
| <link href="libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet"> | ||||
| </body> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner