Spaces:
Runtime error
Runtime error
Commit ·
ffff678
1
Parent(s): 7ac1720
fix: checkbox click
Browse filesFiles changed (2)
- public/app.js+47-21
- public/index.html+1-1
707 unmodified lines708709710711712713714715716717718719720721722723724725726727728729730731302 unmodified lines10341035103610371038103917 unmodified lines10571058105910601061106210631064106510667 unmodified lines1074107510761077107810791080108110821083108410858 unmodified lines10941095109610971098109911004 unmodified lines1105110611071108110911101111707 unmodified linesfileInfo.classList.add('hidden');}const hintContainer = document.getElementById('pg-hints');if(hintContainer) {hintContainer.innerHTML = '';let props = {};if (schema.definition && schema.definition.properties) {props = schema.definition.properties;} else if (schema.definition) {props = schema.definition;}Object.keys(props).forEach(key => {const label = key.replace(/_/g, ' ');const badge = document.createElement('span');badge.className = "text-[10px] text-zinc-400 bg-zinc-900/80 border border-zinc-800 px-2.5 py-1 rounded-full font-mono";badge.innerText = label;hintContainer.appendChild(badge);});}setPlaygroundMode('live');router('playground');302 unmodified lines}};window.updateTempData = function(input, key, index = null) {let val = input.type === 'checkbox' ? input.checked : input.value;if (index !== null) {17 unmodified linesif (Array.isArray(value)) {div.innerHTML = `<div class="flex items-center gap-2 mb-1"><label class="text-[9px] font-bold text-zinc-500 uppercase tracking-wider bg-zinc-900 px-1.5 py-0.5 rounded border border-zinc-800">${label}</label></div><div class="space-y-2 pl-1 border-l-2 border-zinc-800">${value.map((item, index) => `<div class="flex items-center gap-2 group"><input type="text" data-key="${key}" data-array="true" value="${item}"7 unmodified lines` : ''}</div>`).join('')}</div>`;}else if (typeof value === 'boolean') {div.innerHTML = `<div class="flex items-center gap-3 bg-zinc-900/50 p-3 rounded-xl border border-zinc-800 hover:border-zinc-700 transition cursor-pointer group" onclick="this.querySelector('input').click()"><div class="relative flex items-center justify-center w-5 h-5"><input type="checkbox" id="chk-${key}" data-key="${key}" ${value ? 'checked' : ''}onchange="updateTempData(this, '${key}')"8 unmodified linesSTATE.tempDataResult[key] = now;div.innerHTML = `<div class="relative group"><label class="absolute -top-2 left-2 px-1 bg-zinc-950 text-[9px] font-bold text-zinc-500 uppercase tracking-wider z-10 flex items-center gap-1">${label} <span class="w-1.5 h-1.5 rounded-full bg-emerald-500"></span></label>4 unmodified lines}else {div.innerHTML = `<div class="relative group"><label class="absolute -top-2 left-2 px-1 bg-zinc-950 text-[9px] font-bold text-zinc-500 uppercase tracking-wider z-10 group-focus-within:text-emerald-500 transition-colors">${label}</label>707 unmodified lines708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746302 unmodified lines1049105010511052105310541055105610571058105910601061106217 unmodified lines10801081108210831084108510861087108810897 unmodified lines1097109810991100110111021103110411051106110711081109111011118 unmodified lines11201121112211231124112511264 unmodified lines1131113211331134113511361137707 unmodified linesfileInfo.classList.add('hidden');}const headerTitleDiv = document.querySelector('#view-playground .border-b > div > div');const existingHints = document.getElementById('header-hints');if (existingHints) existingHints.remove();const newHintsDiv = document.createElement('div');newHintsDiv.id = 'header-hints';newHintsDiv.className = "flex flex-wrap gap-1 mt-1 items-center";if(schema.definition) {let props = schema.definition.properties || schema.definition;const keys = Object.keys(props);const limit = 7;keys.slice(0, limit).forEach(key => {const span = document.createElement('span');span.className = "text-[9px] text-zinc-500 bg-zinc-900 border border-zinc-800 px-1.5 py-0.5 rounded font-mono";span.innerText = key;newHintsDiv.appendChild(span);});if (keys.length > limit) {const moreSpan = document.createElement('span');moreSpan.className = "text-[9px] text-zinc-600 bg-zinc-900/30 border border-zinc-800/30 px-1.5 py-0.5 rounded italic";moreSpan.innerText = `+${keys.length - limit}`;newHintsDiv.appendChild(moreSpan);}}headerTitleDiv.appendChild(newHintsDiv);const hintContainer = document.getElementById('pg-hints');if(hintContainer) hintContainer.innerHTML = '';setPlaygroundMode('live');router('playground');302 unmodified lines}};window.addArrayItem = function(key) {const currentVal = STATE.tempDataResult[key];if (Array.isArray(currentVal)) {currentVal.push("");renderFormResult(STATE.tempDataResult);}};window.updateTempData = function(input, key, index = null) {let val = input.type === 'checkbox' ? input.checked : input.value;if (index !== null) {17 unmodified linesif (Array.isArray(value)) {div.innerHTML = `<div class="flex items-center gap-2 mb-2"><label class="text-[10px] font-bold text-zinc-500 uppercase tracking-wider bg-zinc-900 border border-zinc-800 px-2 py-1 rounded">${label}</label></div><div class="space-y-2 pl-2 border-l-2 border-zinc-800">${value.map((item, index) => `<div class="flex items-center gap-2 group"><input type="text" data-key="${key}" data-array="true" value="${item}"7 unmodified lines` : ''}</div>`).join('')}<button onclick="addArrayItem('${key}')" class="text-[10px] bg-zinc-900 hover:bg-zinc-800 text-zinc-500 hover:text-white px-3 py-1.5 rounded border border-zinc-800 transition flex items-center gap-1 mt-2"><i class="fa-solid fa-plus"></i> Add Item</button></div>`;}else if (typeof value === 'boolean') {div.innerHTML = `<div class="flex items-center gap-3 bg-zinc-900/50 p-3 rounded-xl border border-zinc-800 hover:border-zinc-700 transition cursor-pointer group" onclick="document.getElementById('chk-${key}').click()"><div class="relative flex items-center justify-center w-5 h-5"><input type="checkbox" id="chk-${key}" data-key="${key}" ${value ? 'checked' : ''}onchange="updateTempData(this, '${key}')"8 unmodified linesSTATE.tempDataResult[key] = now;div.innerHTML = `<div class="relative group mt-3"><label class="absolute -top-2 left-2 px-1 bg-zinc-950 text-[9px] font-bold text-zinc-500 uppercase tracking-wider z-10 flex items-center gap-1">${label} <span class="w-1.5 h-1.5 rounded-full bg-emerald-500"></span></label>4 unmodified lines}else {div.innerHTML = `<div class="relative group mt-3"><label class="absolute -top-2 left-2 px-1 bg-zinc-950 text-[9px] font-bold text-zinc-500 uppercase tracking-wider z-10 group-focus-within:text-emerald-500 transition-colors">${label}</label>
340 unmodified lines341342343344345346340 unmodified lines</main><script src="app.js?v=1.1.5"></script></body></html>340 unmodified lines341342343344345346340 unmodified lines</main><script src="app.js?v=1.1.6"></script></body></html>
public/app.js+47-21
public/index.html+1-1