PageSourceSearch

https://conversiontab.com/build/assets/sql-tool-page-CgyB3vlF.js

js conversiontab.com collected 2026-09-24 10:06:59 UTC 10,197 bytes, 10 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ctResultAccessAd-Dk9whJZs.js","assets/FileSaver.min-BR20wtAe.js","assets/_commonjsHelpers-BosuxZz1.js","assets/ctFullscreenAd-CL-AA_Ul.js","assets/app-gOHIPY12.js"])))=>i.map(i=>d[i]);
2import{_ as J,T as Y}from"./app-gOHIPY12.js";import{s as ee}from"./a11yTextFileTabs-aQqfQEU0.js";import{d as te,M as j,r as ne,b as le}from"./csvSqlCore-M_4k9GW7.js";import{v as M,s as Q}from"./sqlInsertToCsv-Sl-LRUog.js";import{r as ae}from"./fromCsvTargets-Xw7cCC_R.js";import{s as V}from"./buttonBusy-DoyqFlQ8.js";import{c as oe}from"./ctPendingDownload-B21SXRKd.js";import{f as ce}from"./ctBlobExportFinish-D9AIdnhb.js";import"./papaparse.min-DtqB8VRF.js";import"./_commonjsHelpers-BosuxZz1.js";import"./FileSaver.min-BR20wtAe.js";import"./csvExportFormats-DPHu0Bph.js";import"./formatHubIcsVcf-BssvIWBl.js";import"./xlsx-D_0l8YDs.js";import"./ctFullscreenAd-CL-AA_Ul.js";const ie="File is empty",se=`The file size exceeds the limit of ${j}MB`,z="INSERT INTO users (id, name, email) VALUES (1, 'Ann', '[email protected]'), (2, 'Lee', '[email protected]');";function i(s,c=!0){const d=document.getElementById("ctSqlToast"),y=document.getElementById("ctSqlToastBody");if(!d||!y){window.alert(s);return}y.textContent=s,d.classList.remove("text-bg-success","text-bg-danger"),d.classList.add(c?"text-bg-danger":"text-bg-success"),Y.getOrCreateInstance(d,{delay:4500}).show()}function H(s){if(!s)return"";const c=s.value.trim();if(c==="")return"";const d=parseInt(c,10);return Number.isNaN(d)?"":d}function Z(){return{FirstRowIsColumnNames:!0,limitOfLines:"",skipOfLines:"",fieldSeprator:",",customFieldSeparator:"",primaryKey:"Primary_key",keepOriginalFieldNames:!0,encloseFieldNames:!0,encloseFieldNamesWith:"backtick",columns:[],schemaTableOrViewName:"table_name"}}function re(s){return{json:"json",xml:"xml",csv:"csv",html:"html",yaml:"yaml",ics:"ics",vcf:"vcf"}[s]||"txt"}function Te(){var q,w,B,N,R,$,A,_,O,D,P;const s=document.getElementById("ct-sql-tool-root");if(!s)return;const c=(s.dataset.ctSqlTarget||"csv").toLowerCase(),d=c==="xlsx"||c==="pdf",y=c==="xlsx"?"converted_data":"converted",K=c==="xlsx"?".xlsx":".pdf";let l=Z(),r="",g="",b=[],I,h=null,p="";const v=oe(),e={ta:document.getElementById("ctSqlText"),fileInput:document.getElementById("ctSqlFile"),fileZone:document.getElementById("ctSqlFileZone"),btnClear:document.getElementById("ctSqlClear"),btnSample:document.getElementById("ctSqlSample"),tabText:document.getElementById("ctSqlTabText"),tabFile:document.getElementById("ctSqlTabFile"),panelText:document.getElementById("ctSqlPanelText"),panelFile:document.getElementById("ctSqlPanelFile"),chkFirstRow:document.getElementById("ctSqlFirstRow"),limitLines:document.getElementById("ctSqlLimitLines"),skipLines:document.getElementById("ctSqlSkipLines"),chkEnclose:document.getElementById("ctSqlEnclose"),encloseRadios:s.querySelectorAll('input[name="ct_sql_enclose"]'),schemaName:document.getElementById("ctSqlSchema"),colBody:document.getElementById("ctSqlColBody"),resultTa:document.getElementById("ctSqlResult"),fileName:document.getElementById("ctSqlFileName"),btnCopy:document.getElementById("ctSqlCopy"),btnDownload:document.getElementById("ctSqlDownload"),btnConvert:document.getElementById("ctSqlBtnConvert"),fileConvert:document.getElementById("ctSqlFileConvert")};function E(){var n,o,a;l.FirstRowIsColumnNames=((n=e.chkFirstRow)==null?void 0:n.checked)!==!1,l.limitOfLines=H(e.limitLines),l.skipOfLines=H(e.skipLines),l.encloseFieldNames=((o=e.chkEnclose)==null?void 0:o.checked)!==!1,l.schemaTableOrViewName=((a=e.schemaName)==null?void 0:a.value)||"table_name",l.fieldSeprator=",",l.customFieldSeparator="";const t=[...e.encloseRadios||[]].find(f=>f.checked);l.encloseFieldNamesWith=t?t.value:"backtick"}function C(){var t;e.chkFirstRow&&(e.chkFirstRow.checked=l.FirstRowIsColumnNames),e.limitLines&&(e.limitLines.value=l.limitOfLines===""?"":String(l.limitOfLines)),e.skipLines&&(e.skipLines.value=l.skipOfLines===""?"":String(l.skipOfLines)),e.chkEnclose&&(e.chkEnclose.checked=l.encloseFieldNames),e.schemaName&&(e.schemaName.value=l.schemaTableOrViewName),(t=e.encloseRadios)==null||t.forEach(n=>
2{n.checked=n.value===l.encloseFieldNamesWith})}function x(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function W(t){return x(t).replace(/'/g,"&#39;")}function k(){if(!e.colBody)return;e.colBody.innerHTML="";const t=l.columns||[];if(!t.length){e.colBody.innerHTML='<tr><td colspan="8" class="text-body-secondary small">Paste valid INSERT SQL to load columns.</td></tr>';return}t.forEach((n,o)=>{const a=document.createElement("tr");a.innerHTML=`
3        <td>${n.colNumber}</td>
4        <td><input type="text" class="form-control form-control-sm ct-sql-col-name" data-i="${o}" value="${W(n.fieldName)}"></td>
5        <td class="small">${x(String(n.dataType))}</td>
6        <td class="small">${x(String(n.maxSize??""))}</td>
7        <td class="text-center"><input type="checkbox" class="form-check-input ct-sql-col-key" data-i="${o}" ${n.isKey?"checked":""}></td>
8        <td class="text-center"><input type="checkbox" class="form-check-input ct-sql-col-inc" data-i="${o}" ${n.isInclude!==!1?"checked":""}></td>
9        <td class="text-center"><input type="checkbox" class="form-check-input ct-sql-col-trim" data-i="${o}" ${n.isTrim?"checked":""}></td>
10        <td class="text-center"><input type="checkbox" class="form-check-input ct-sql-col-null" data-i="${o}" ${n.isNull?"checked":""}></td>`,e.colBody.appendChild(a)}),e.colBody.querySelectorAll(".ct-sql-col-name").forEach(n=>{n.addEventListener("input",()=>{const o=+n.dataset.i;l.columns[o].fieldName=n.value})}),e.colBody.querySelectorAll(".ct-sql-col-key").forEach(n=>{n.addEventListener("change",()=>{const o=+n.dataset.i;l.columns[o].isKey=n.checked})}),e.colBody.querySelectorAll(".ct-sql-col-inc").forEach(n=>{n.addEventListener("change",()=>{const o=+n.dataset.i;l.columns[o].isInclude=n.checked})}),e.colBody.querySelectorAll(".ct-sql-col-trim").forEach(n=>{n.addEventListener("change",()=>{const o=+n.dataset.i;l.columns[o].isTrim=n.checked})}),e.colBody.querySelectorAll(".ct-sql-col-null").forEach(n=>{n.addEventListener("change",()=>{const o=+n.dataset.i;l.columns[o].isNull=n.checked})})}async function u(){E();const t=r.trim();if(!t||!M(t)){l.columns=[],k();return}try{const n=Q(t),o=await le(n,l);l={...l,columns:o},k()}catch{l.columns=[],k()}}function U(){h=null,p="",v.clear()}async function X(t){const n=await ce(v,{blob:t,fileNameEl:e.fileName,defaultBase:y,ext:K,btnDownload:e.btnDownload});h=t,p=n,g="",e.resultTa&&(e.resultTa.value=""),e.btnCopy&&(e.btnCopy.disabled=!0),i(`Downloading ${n}…`,!1)}function L(t){U(),g=t,e.resultTa&&(e.resultTa.value=t),!d&&e.fileName&&(e.fileName.disabled=!t),e.btnDownload&&(e.btnDownload.disabled=!t),e.btnCopy&&(e.btnCopy.disabled=!t)}function m(){const t=r.trim().length>0;e.btnClear&&(e.btnClear.disabled=!t),e.btnSample&&(e.btnSample.disabled=t),e.btnConvert&&(e.btnConvert.disabled=!t),e.fileConvert&&(e.fileConvert.disabled=!b.length)}async function F(){E();const t=r.trim();if(!t){i("Paste SQL first");return}if(!M(t)){i("Query is invalid for this tool (expect MySQL INSERT … VALUES …).");return}let n;try{n=Q(t)}catch(a){i((a==null?void 0:a.message)||String(a));return}const o={...l,fieldSeprator:",",customFieldSeparator:""};V([e.btnConvert],!0);try{const a=await ae(c,n,o,{showToast:i});a&&typeof a=="object"&&a.kind==="download-blob"?await X(a.blob):L(typeof a=="string"?a:"")}catch(a){i((a==null?void 0:a.message)||String(a))}finally{V([e.btnConvert],!1),m()}}(q=e.ta)==null||q.addEventListener("input",()=>{r=e.ta.value,clearTimeout(I),I=setTimeout(()=>{u(),m()},200),m()}),[e.chkFirstRow,e.limitLines,e.skipLines,e.chkEnclose,e.schemaName,...Array.from(e.encloseRadios||[])].forEac
10h(t=>{t==null||t.addEventListener("change",()=>{E(),u()}),t==null||t.addEventListener("input",()=>{E(),u()})}),(w=e.btnClear)==null||w.addEventListener("click",()=>{r="",e.ta&&(e.ta.value=""),b=[],e.fileInput&&(e.fileInput.value=""),l=Z(),C(),L(""),e.fileName&&(e.fileName.value=d?y:""),u(),m()}),(B=e.btnSample)==null||B.addEventListener("click",()=>{r.trim()||(r=z,e.ta&&(e.ta.value=z),u(),m())});function T(t){var o,a,f,S;const n=t==="text";(o=e.tabText)==null||o.classList.toggle("active",n),(a=e.tabFile)==null||a.classList.toggle("active",!n),(f=e.panelText)==null||f.classList.toggle("d-none",!n),(S=e.panelFile)==null||S.classList.toggle("d-none",n),ee({tabText:e.tabText,tabFile:e.tabFile,panelText:e.panelText,panelFile:e.panelFile,isText:n}),L(""),t==="text"?(b=[],e.fileInput&&(e.fileInput.value="")):(r="",e.ta&&(e.ta.value="")),u(),m()}(N=e.tabText)==null||N.addEventListener("click",()=>T("text")),(R=e.tabFile)==null||R.addEventListener("click",()=>T("file")),($=e.fileInput)==null||$.addEventListener("change",t=>{var n;b=(n=t.target.files)!=null&&n.length?[t.target.files[0]]:[],m()}),(A=e.fileZone)==null||A.addEventListener("click",()=>{var t;return(t=e.fileInput)==null?void 0:t.click()}),(_=e.btnCopy)==null||_.addEventListener("click",async()=>{const{gateResultCopy:t}=await J(async()=>{const{gateResultCopy:n}=await import("./ctResultAccessAd-Dk9whJZs.js");return{gateResultCopy:n}},__vite__mapDeps([0,1,2,3,4]));try{await t(async()=>{await navigator.clipboard.writeText(g)}),i("Copied!",!1)}catch{i("Copy failed",!0)}}),(O=e.btnDownload)==null||O.addEventListener("click",()=>{var a,f;if(h){const S=(((a=e.fileName)==null?void 0:a.value)||"").trim()||p.replace(/\.[^.]+$/,"")||"converted",G=p.includes(".")?p.slice(p.lastIndexOf(".")):c==="pdf"?".pdf":".xlsx";v.setSingle(h,`${S}${G}`),v.runDownloadClick();return}const t=(((f=e.fileName)==null?void 0:f.value)||"").trim(),n=re(c),o=t?`${t}.${n}`:`converted.${n}`;te(g,o)}),(D=e.btnConvert)==null||D.addEventListener("click",()=>{F()}),(P=e.fileConvert)==null||P.addEventListener("click",async()=>{const t=b[0];if(!t){i("Choose a file first");return}if(t.size/(1024*1024)>j){i(se);return}try{r=await ne(t),e.ta&&(e.ta.value=r),T("text")}catch{i("Could not read file");return}if(r===""){i(ie);return}await u(),m(),await F()}),C(),u(),m()}export{Te as initSqlToolPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.