Browse Source

Added scaling to animator

Toby Chui 9 months ago
parent
commit
96c4279d80

+ 63 - 1
sd_card/web/animator.html

@@ -33,7 +33,6 @@
 			position: relative;
 			flex-wrap: wrap;
             width: calc(32 * (20px + 2px * 2));
-			
         }
 		
 		#dotmatrix{
@@ -113,6 +112,25 @@
 			margin: 0.4em;
 			margin-top: 0.6em;
 		}
+
+		.rotate-message {
+			font-family: Arial, Helvetica, sans-serif;
+			display: none;
+			position: fixed;
+			top: 0;
+			left: 0;
+			width: calc(100% - 1em);
+			height: 100%;
+			padding-left: 0.5em;
+			background-color: rgba(0, 0, 0, 0.8);
+			color: white;
+			display: flex;
+			justify-content: center;
+			align-items: center;
+			font-size: 1.3em;
+			text-align: center;
+			z-index: 9999;
+		}
     </style>
 </head>
 <body>
@@ -142,6 +160,12 @@
 			</div>
 			
 		</div>
+	</div>
+	<div id="requireLandscapeMode" class="rotate-message">
+		<div>
+			<p style="font-size: 2em;">(´・ω・`)</p>
+			<p>Please rotate your device to landscape mode.</p>
+		</div>
 		
 	</div>
     <script>
@@ -268,6 +292,44 @@
 			drawFrameFromIntArray(bitArray);
         }
 
+		/* RWD and mobile interface */
+		let isMobile = false;
+		if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
+            isMobile = true;
+		}
+
+		function calculateScale(windowWidth, windowHeight, minWidth=768, minHeight=460) {
+			// Calculate the scale ratios for both width and height
+			const widthRatio = windowWidth / minWidth;
+			const heightRatio = windowHeight / minHeight;
+
+			// Choose the smaller ratio to ensure the entire div fits within the screen
+			return Math.min(widthRatio, heightRatio);
+		}
+
+		function updateRWD(){
+			if (isMobile){
+				if (window.innerHeight > window.innerWidth){
+					$("#grid-container").hide();
+					$("#requireLandscapeMode").show();
+				}else{
+					$("#grid-container").show();
+					$("#requireLandscapeMode").hide();
+				}
+
+				//Scale down the grids to size
+				//768 * 460
+				const scale = calculateScale(window.innerWidth, window.innerHeight - 24);
+				$("#grid-container").css("scale", scale);
+				$("#grid-container").css("margin-top", "24px");
+			}
+		}
+		
+		updateRWD();
+		$(window).on("resize", function(){
+			updateRWD();
+		})
+
     </script>
 </body>
 </html>

+ 1 - 0
sd_card/web/img/action.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#75FB4C"><path d="M520-40v-240l-84-80-40 176-276-56 16-80 192 40 64-324-72 28v136h-80v-188l158-68q35-15 51.5-19.5T480-720q21 0 39 11t29 29l40 64q26 42 70.5 69T760-520v80q-66 0-123.5-27.5T540-540l-24 120 84 80v300h-80Zm20-700q-33 0-56.5-23.5T460-820q0-33 23.5-56.5T540-900q33 0 56.5 23.5T620-820q0 33-23.5 56.5T540-740Z"/></svg>

+ 1 - 0
sd_card/web/img/animation.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#EA3323"><path d="M360-80q-58 0-109-22t-89-60q-38-38-60-89T80-360q0-81 42-148t110-102q20-39 49.5-68.5T350-728q33-68 101-110t149-42q58 0 109 22t89 60q38 38 60 89t22 109q0 85-42 150T728-350q-20 39-49.5 68.5T610-232q-35 68-102 110T360-80Zm0-80q33 0 63.5-10t56.5-30q-58 0-109-22t-89-60q-38-38-60-89t-22-109q-20 26-30 56.5T160-360q0 42 16 78t43 63q27 27 63 43t78 16Zm120-120q33 0 64.5-10t57.5-30q-59 0-110-22.5T403-403q-38-38-60.5-89T320-602q-20 26-30 57.5T280-480q0 42 15.5 78t43.5 63q27 28 63 43.5t78 15.5Zm120-120q18 0 34.5-3t33.5-9q22-60 6.5-115.5T621-621q-38-38-93.5-53.5T412-668q-6 17-9 33.5t-3 34.5q0 42 15.5 78t43.5 63q27 28 63 43.5t78 15.5Zm160-78q20-26 30-57.5t10-64.5q0-42-15.5-78T741-741q-27-28-63-43.5T600-800q-35 0-65.5 10T478-760q59 0 110 22.5t89 60.5q38 38 60.5 89T760-478Z"/></svg>

+ 1 - 0
sd_card/web/img/checkmark.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#75FB4C"><path d="m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>

+ 1 - 0
sd_card/web/img/code.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#5985E1"><path d="M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z"/></svg>

+ 1 - 0
sd_card/web/img/folder.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#FFFF55"><path d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"/></svg>

+ 1 - 0
sd_card/web/img/menu.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#FFFFFF"><path d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg>

+ 71 - 5
sd_card/web/index.html

@@ -1,13 +1,79 @@
 <!DOCTYPE HTML>
 <html>
   <head>
-    <title>Captive Portal</title>
+    <title>(´・ω・`)</title>
+    <script src="./jquery.min.js"></script>
+    <link rel="stylesheet" href="./main.css"/>
     <meta name="viewport" content="width=device-width, initial-scale=1">
   </head>
   <body>
-    <h3>Captive Portal</h3>
-    <br>
-    <br>
-	<p>Hello World!</p>
+    <!-- Main contents of the webapp -->
+    <div id="menu">
+      <div class="container">
+        <span class="logo">(´・ω・`)</span>
+      </div>
+      <button onclick="toggleSideMenu()" class="togglemenu button">
+        <img class="btnicon" src="img/menu.svg">
+      </button>
+    </div>
+    <div class="container">
+      <div class="header">
+        <img src="img/checkmark.svg" >
+        <span>Useless Robot Connected<br>
+          <small>IP Address: <span id="ipaddr">Unknown</span></small></span>
+      </div>
+      
+      <div class="divider"></div>
+      <h3>Quick Actions</h3>
+      <p>Hello World!</p>
+    </div>
+    
+    <!-- Side bar for other functions-->
+    <div id="sidebarWrapper">
+      <div id="blurcover"></div>
+      <div id="sidebar">
+        <div class="item">
+          <b>Advance Functions</b>
+        </div>
+        <div class="divider"></div>
+        <a class="clickable item" href="animator.html">
+          <img src="img/animation.svg"> Animation Editor
+        </a>
+        <a class="clickable item">
+          <img src="img/action.svg"> Action Programmer
+        </a>
+        <a class="clickable item">
+          <img src="img/folder.svg"> SD Browser
+        </a>
+        <a class="clickable item">
+          <img src="img/code.svg"> Developer Tools
+        </a>
+        <div class="item">
+          <small>Cute Useless Robot v1.0</small>
+        </div>
+      </div>
+    </div>
+  <script>
+    function toggleSideMenu(){
+      var left = $('#sidebar').offset().left;  // Get the calculated left position
+      if (left >= window.innerWidth || left == 0){
+        //side bar is hidden
+        $("#sidebarWrapper").fadeIn('fast');
+        $("#sidebar").css({left:window.innerWidth + "px"}).animate({"left": (window.innerWidth - $('#sidebar').width())+ "px"}, "fast", function(){
+          
+        });
+      }else{
+        //side bar is shown
+        $("#sidebar").css({left:left}).animate({"left": window.innerWidth + "px"}, "fast", function(){
+          $("#sidebarWrapper").fadeOut('fast');
+        });
+      }
+      
+      
+    }
+    $("#blurcover").on("click", function(){
+      toggleSideMenu();
+    })
+  </script>
   </body>
 </html>

+ 150 - 0
sd_card/web/main.css

@@ -0,0 +1,150 @@
+/*
+    👾 Cute Useless Robot CSS theme (´・ω・`)
+
+    Note: This css theme is designed to be completely
+    off-grid, do not include url or external resources
+*/
+
+@font-face {
+    font-family: 'mulishB';
+    src: url('src/Mulish-Bold.ttf')  format('truetype'), /* Safari, Android, iOS */
+}
+
+@font-face {
+    font-family: 'mulishR';
+    src: url('src/Mulish-Regular.ttf')  format('truetype'), /* Safari, Android, iOS */
+}
+
+:root{
+    --theme-base: #000000;
+    --theme-dark: #141414;
+    --theme-divider: #252525;
+    --theme-dark-alt: #282828;
+    --theme-active: #230046;
+    --theme-primary: #E8E9EB;
+    --theme-secondary: #320064;
+    --theme-text-color: white;
+}
+
+body{
+    margin: 0 !important;
+    font-family: 'mulishR';
+    color: var(--theme-text-color);
+    background-color: var(--theme-dark);
+}
+
+/* Global CSS Rules */
+.button{
+    border: 1px solid transparent;
+    background-color: transparent;
+    transition: background-color ease-in-out 0.1s, opacity ease-in-out 0.1s;
+    cursor: pointer;
+}
+
+.button:hover{
+    background-color: rgba(255,255,255,0.1);
+    opacity: 0.8;
+}
+
+.button .btnicon{
+    width: 100%;
+    height: 100%;
+}
+
+.container{
+    padding: 0.6em;
+    padding-left: 1.2em;
+    padding-right: 1.2em;
+    width: 100%;
+    position: relative;
+    box-sizing: border-box; 
+}
+
+.header{
+    display: flex;
+    align-items: center;
+}
+
+.header img {
+    margin-right: 10px; 
+}
+
+.divider{
+    width: 100%;
+    margin-top: 1em;
+    border-bottom: 1px solid var(--theme-divider);
+}
+
+a:link { 
+    text-decoration: none; 
+} 
+
+
+/* Side bar */
+#sidebarWrapper{
+    width: 100%;
+    height: 100%;
+    position: relative;
+    display:none;
+}
+
+#blurcover{
+    width: 100%;
+    height: 100%;
+    position: fixed;
+    top:0;
+    right:0;
+    background-color: rgba(0,0,0,0.7);
+}
+
+#sidebar{
+    height: 100vh;
+    position: fixed;
+    right: 0;
+    top: 0;
+    width: 250px;
+    background-color: var(--theme-dark-alt);
+    padding-top: 1em;
+    box-sizing: border-box; 
+}
+
+#sidebar .item{
+    width: 100%;
+    padding: 0.6em;
+    font-size: 1em;
+    display: flex;
+    align-items: center;
+    color: white;
+}
+
+#sidebar .item.clickable{
+    cursor: pointer;
+}
+
+#sidebar .item img{
+    margin-right: 0.6em; 
+}
+
+#sidebar .item.clickable:hover{
+    background-color: var( --theme-active);
+}
+
+/* Top Menu */
+#menu{
+    background-color: var(--theme-base);
+    color: white;
+}
+
+#menu .logo{
+    font-size: 1.5em;
+    font-family: 'mulishB';
+}
+
+#menu .togglemenu{
+    position: absolute;
+    right: 1.2em;
+    top: 0.4em;
+    height: 38px;
+    width: 38px;
+}
+

BIN
sd_card/web/src/Mulish-Bold.ttf


BIN
sd_card/web/src/Mulish-Regular.ttf


BIN
sd_card/web/src/tiny5.ttf