|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <html lang="en"> |
3 | | - <head> |
4 | | - <meta charset="UTF-8"> |
5 | | - <title>Labs64 NetLicensing JavaScript Client Demo</title> |
6 | | - <script src="../dist/index.global.js"></script> |
7 | | - <script src="client-demo.js"></script> |
8 | | - <style> |
9 | | - .console-log-div { |
10 | | - border: 1px solid gray; |
11 | | - padding: 5px 10px; |
12 | | - border-radius: 5px; |
13 | | - width: 95% !important; |
14 | | - background-color: #efefef; |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Labs64 NetLicensing JavaScript Client Demo</title> |
| 7 | + |
| 8 | + <!-- Load Tailwind CSS for modern styling --> |
| 9 | + <script src="https://cdn.tailwindcss.com"></script> |
| 10 | + |
| 11 | + <!-- Configure Tailwind theme for Labs64 Brand Color --> |
| 12 | + <script> |
| 13 | + tailwind.config = { |
| 14 | + theme: { |
| 15 | + extend: { |
| 16 | + colors: { |
| 17 | + brand: { |
| 18 | + DEFAULT: '#E14817', |
| 19 | + hover: '#C23E14' |
| 20 | + } |
| 21 | + } |
| 22 | + } |
15 | 23 | } |
16 | | - </style> |
17 | | - </head> |
18 | | - |
19 | | - <body> |
20 | | - <h1><p align="center"><strong>Labs64 <a href="https://netlicensing.io">NetLicensing</a><br/>JavaScript Client |
21 | | - Demo</strong></p></h1> |
22 | | - <p align="center">This demo showcases <a href="https://netlicensing.io/wiki/restful-api">RESTful API</a> access |
23 | | - to NetLicensing’s core features.</p> |
24 | | - <p align="center"> |
25 | | - <input type="button" value="Execute" onclick="NetLicensingDemo();"/> |
26 | | - <input type="button" value="Clear" onclick="clearBox('console-log-text')"/> |
27 | | - </p> |
28 | | - |
29 | | - <script src="https://cdn.jsdelivr.net/npm/console-log-div@0.6.3/console-log-div.min.js"></script> |
30 | | - </body> |
| 24 | + } |
| 25 | + </script> |
| 26 | + |
| 27 | + <!-- Load latest NetLicensing Client from unpkg --> |
| 28 | + <script src="https://unpkg.com/netlicensing-client@latest/dist/index.global.js"></script> |
| 29 | + |
| 30 | + <!-- Load your demo logic (Ensure this matches your local file name) --> |
| 31 | + <script src="client-demo.js"></script> |
| 32 | + |
| 33 | + <style> |
| 34 | + /* Custom scrollbar for the console output */ |
| 35 | + #console-log-text::-webkit-scrollbar { |
| 36 | + width: 10px; |
| 37 | + } |
| 38 | + #console-log-text::-webkit-scrollbar-track { |
| 39 | + background: #111827; |
| 40 | + border-left: 1px solid #374151; |
| 41 | + } |
| 42 | + #console-log-text::-webkit-scrollbar-thumb { |
| 43 | + background: #4b5563; |
| 44 | + border-radius: 5px; |
| 45 | + border: 2px solid #111827; |
| 46 | + } |
| 47 | + #console-log-text::-webkit-scrollbar-thumb:hover { |
| 48 | + background: #6b7280; |
| 49 | + } |
| 50 | + |
| 51 | + /* Flex layout setup */ |
| 52 | + body { |
| 53 | + display: flex; |
| 54 | + flex-direction: column; |
| 55 | + height: 100vh; |
| 56 | + margin: 0; |
| 57 | + overflow: hidden; |
| 58 | + } |
| 59 | + |
| 60 | + .main-container { |
| 61 | + flex: 1; |
| 62 | + display: flex; |
| 63 | + flex-direction: column; |
| 64 | + padding-bottom: 2rem; |
| 65 | + min-height: 0; /* Crucial for flex child to allow inner scrolling */ |
| 66 | + } |
| 67 | + |
| 68 | + .terminal-container { |
| 69 | + flex: 1; |
| 70 | + display: flex; |
| 71 | + flex-direction: column; |
| 72 | + min-height: 0; /* Crucial for flex child to allow inner scrolling */ |
| 73 | + } |
| 74 | + |
| 75 | + #console-log-text { |
| 76 | + flex: 1; |
| 77 | + overflow-y: auto; /* Enables vertical scrolling */ |
| 78 | + word-wrap: break-word; |
| 79 | + } |
| 80 | + |
| 81 | + /* Prevent layout shift during auto-scroll */ |
| 82 | + .log-entry { |
| 83 | + margin-bottom: 0.5rem; |
| 84 | + white-space: pre-wrap; |
| 85 | + word-break: break-all; |
| 86 | + } |
| 87 | + </style> |
| 88 | +</head> |
| 89 | +<body class="bg-gray-50 font-sans text-gray-800"> |
| 90 | + |
| 91 | + <div class="main-container w-[1024px] max-w-[1024px] mx-auto pt-8 px-4"> |
| 92 | + |
| 93 | + <!-- Header Section --> |
| 94 | + <div class="text-center mb-6 shrink-0"> |
| 95 | + <h1 class="text-4xl font-extrabold text-gray-900 tracking-tight mb-2"> |
| 96 | + <span class="block text-brand">Labs64</span> |
| 97 | + <a href="https://netlicensing.io/" target="_blank" class="hover:text-brand-hover transition-colors"> |
| 98 | + NetLicensing JavaScript Client |
| 99 | + </a> |
| 100 | + </h1> |
| 101 | + <p class="mt-2 text-lg text-gray-500 max-w-2xl mx-auto"> |
| 102 | + Interactive demo showcasing <a href="https://netlicensing.io/wiki/restful-api" target="_blank" class="text-brand hover:underline">RESTful API</a> access. |
| 103 | + </p> |
| 104 | + </div> |
| 105 | + |
| 106 | + <!-- Controls Section --> |
| 107 | + <div class="flex justify-center gap-4 mb-6 shrink-0"> |
| 108 | + <button |
| 109 | + onclick="NetLicensingDemo()" |
| 110 | + class="inline-flex items-center px-6 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-brand hover:bg-brand-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand transition-colors duration-200"> |
| 111 | + <svg class="w-5 h-5 mr-2 -ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> |
| 112 | + Execute Demo |
| 113 | + </button> |
| 114 | + |
| 115 | + <button |
| 116 | + onclick="clearBox('console-log-text')" |
| 117 | + class="inline-flex items-center px-6 py-2 border border-gray-300 text-base font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand transition-colors duration-200 shadow-sm"> |
| 118 | + <svg class="w-5 h-5 mr-2 -ml-1 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg> |
| 119 | + Clear Console |
| 120 | + </button> |
| 121 | + </div> |
| 122 | + |
| 123 | + <!-- Terminal Output Section --> |
| 124 | + <div class="terminal-container bg-gray-900 rounded-lg shadow-xl overflow-hidden border border-gray-700 w-full relative"> |
| 125 | + <!-- Mac-style window header --> |
| 126 | + <div class="bg-gray-800 px-4 py-2 border-b border-gray-700 flex items-center shrink-0 z-10"> |
| 127 | + <div class="flex space-x-2"> |
| 128 | + <div class="w-3 h-3 rounded-full bg-red-500"></div> |
| 129 | + <div class="w-3 h-3 rounded-full bg-yellow-500"></div> |
| 130 | + <div class="w-3 h-3 rounded-full bg-green-500"></div> |
| 131 | + </div> |
| 132 | + <div class="mx-auto text-gray-400 text-xs font-mono">demo-output.log</div> |
| 133 | + </div> |
| 134 | + |
| 135 | + <!-- Output container now takes up remaining screen height AND allows scrolling --> |
| 136 | + <div class="p-4 font-mono text-sm w-full" id="console-log-text"> |
| 137 | + <div class="text-gray-500 mb-2">Ready. Click 'Execute Demo' to start the NetLicensing API simulation...</div> |
| 138 | + </div> |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + |
| 142 | + <!-- Intercept Console Output --> |
| 143 | + <script> |
| 144 | + (function() { |
| 145 | + const oldLog = console.log; |
| 146 | + const oldError = console.error; |
| 147 | + const oldWarn = console.warn; |
| 148 | + const logger = document.getElementById('console-log-text'); |
| 149 | + |
| 150 | + function formatArgs(args) { |
| 151 | + return Array.from(args).map(arg => { |
| 152 | + if (arg instanceof Error) { |
| 153 | + return arg.stack || arg.message; |
| 154 | + } |
| 155 | + if (typeof arg === 'object' && arg !== null) { |
| 156 | + try { |
| 157 | + return JSON.stringify(arg, null, 2); |
| 158 | + } catch (e) { |
| 159 | + return String(arg); |
| 160 | + } |
| 161 | + } |
| 162 | + return String(arg); |
| 163 | + }).join(' '); |
| 164 | + } |
| 165 | + |
| 166 | + function appendLog(args, colorClass, prefixChar = '>') { |
| 167 | + const msg = formatArgs(args); |
| 168 | + const div = document.createElement('div'); |
| 169 | + div.className = `log-entry ${colorClass}`; |
| 170 | + |
| 171 | + const prefix = document.createElement('span'); |
| 172 | + prefix.className = 'text-[#E14817] mr-2 select-none font-bold'; |
| 173 | + prefix.textContent = prefixChar; |
| 174 | + |
| 175 | + div.appendChild(prefix); |
| 176 | + div.appendChild(document.createTextNode(msg)); |
| 177 | + |
| 178 | + logger.appendChild(div); |
| 179 | + |
| 180 | + // Ensure the scroll goes all the way to the newly added item |
| 181 | + // Use requestAnimationFrame to ensure the DOM has updated before calculating height |
| 182 | + requestAnimationFrame(() => { |
| 183 | + logger.scrollTop = logger.scrollHeight; |
| 184 | + }); |
| 185 | + } |
| 186 | + |
| 187 | + console.log = function() { |
| 188 | + oldLog.apply(console, arguments); |
| 189 | + appendLog(arguments, 'text-green-400'); |
| 190 | + }; |
| 191 | + |
| 192 | + console.error = function() { |
| 193 | + oldError.apply(console, arguments); |
| 194 | + appendLog(arguments, 'text-red-400', '✖'); |
| 195 | + }; |
| 196 | + |
| 197 | + console.warn = function() { |
| 198 | + oldWarn.apply(console, arguments); |
| 199 | + appendLog(arguments, 'text-yellow-400', '⚠'); |
| 200 | + }; |
| 201 | + |
| 202 | + window.onerror = function(message, source, lineno, colno, error) { |
| 203 | + console.error("Uncaught Error: " + message); |
| 204 | + return false; |
| 205 | + }; |
| 206 | + |
| 207 | + window.addEventListener("unhandledrejection", function(event) { |
| 208 | + console.error("Unhandled Promise Rejection: " + (event.reason ? event.reason.stack || event.reason : event)); |
| 209 | + }); |
| 210 | + |
| 211 | + window.clearBox = function(elementID) { |
| 212 | + const el = document.getElementById(elementID); |
| 213 | + if (el) { |
| 214 | + el.innerHTML = '<div class="text-gray-500 mb-2">Console cleared. Ready.</div>'; |
| 215 | + } |
| 216 | + }; |
| 217 | + })(); |
| 218 | + </script> |
| 219 | +</body> |
31 | 220 | </html> |
0 commit comments