anurag008w commited on
Commit
f32ab0f
·
1 Parent(s): c07b8ab

Implement auto-import and live typing for env input

Browse files

Added event listeners for auto-import and live typing features in the env-builder.

Files changed (1) hide show
  1. env-builder.js +27 -0
env-builder.js CHANGED
@@ -2281,6 +2281,33 @@ $('applyImport').onclick = () => {
2281
  alert(e.message);
2282
  }
2283
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2284
  $('addCustom').onclick = () => addCustomRow();
2285
  $('applyBundle').onclick = () => {
2286
  try {
 
2281
  alert(e.message);
2282
  }
2283
  };
2284
+
2285
+ // Auto-import: paste karo aur turant parse + apply ho jaata hai
2286
+ $('importText').addEventListener('paste', () => {
2287
+ setTimeout(() => {
2288
+ try {
2289
+ const val = $('importText').value.trim();
2290
+ if (!val) return;
2291
+ applyObj(parseEnv(val), true);
2292
+ showToast('Auto-imported ✓');
2293
+ } catch (e) {
2294
+ showToast('Import failed');
2295
+ }
2296
+ }, 0);
2297
+ });
2298
+
2299
+ // Live typing: jaise jaise type karo env format mein, bundle banta jaata hai
2300
+ $('importText').addEventListener('input', () => {
2301
+ const val = $('importText').value.trim();
2302
+ if (!val) return;
2303
+ // Sirf agar valid env/bundle format lag raha ho tabhi auto-apply
2304
+ const looksLikeEnv = val.includes('=') || val.startsWith('{') || /^[A-Za-z0-9_\-]{20,}$/.test(val);
2305
+ if (looksLikeEnv) {
2306
+ try {
2307
+ applyObj(parseEnv(val), true);
2308
+ } catch (e) { /* silent — user abhi type kar raha hai */ }
2309
+ }
2310
+ });
2311
  $('addCustom').onclick = () => addCustomRow();
2312
  $('applyBundle').onclick = () => {
2313
  try {