-
Notifications
You must be signed in to change notification settings - Fork 1
/
sf.debug.min.js
138 lines (138 loc) · 12.1 KB
/
sf.debug.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
(()=>{if(window.innerWidth<992)return;let e="server.wized.com"==location.host,t=location.host.endsWith(".webflow.io");if(!e&&!t)return;function r(){let e="sfp-memory-js",t=StudioForm.config.eventPrefix;StudioForm.forEach(r=>{let n=r.elements,l=n.mask,a=e+"-"+r.name,s="true"==document.body.getAttribute("sfp-memory-local-storage")?localStorage:sessionStorage;if(l.getAttribute(e))return;l.setAttribute(e,"");let c=s.getItem(a),d=s.getItem(a+"-record");async function p(e){let t=await o(a),r=t.transaction(["files"],"readwrite"),i=r.objectStore("files"),n=e.name+Date.now(),l={id:n,data:e};return new Promise((e,r)=>{let o=i.put(l);o.onsuccess=function(){t.close(),e(n)},o.onerror=function(){t.close(),r(Error("Error storing file"))}})}c&&d&&i(r,JSON.parse(c),JSON.parse(d)),["change",t+"transition"].forEach(e=>l.addEventListener(e,async()=>{if("true"!=localStorage.getItem("debugMode"))return;let e=r.data(),t=Object.keys(e).map(async t=>{let r=e[t],o=[];r instanceof File&&o.push(r),Array.isArray(r)&&r[0]instanceof File&&r.forEach(e=>o.push(e));let i=o.map(async(r,i)=>{let n="__SFP_FILE__"+await p(r);o.length>1?e[t][i]=n:e[t]=n});await Promise.all(i)});await Promise.all(t),s.setItem(a,JSON.stringify(e)),s.setItem(a+"-record",JSON.stringify(r.record))}))})}function o(e){return new Promise((t,r)=>{let o=indexedDB.open(e,1);o.onupgradeneeded=function(e){let t=e.target.result;t.createObjectStore("files",{keyPath:"id"})},o.onsuccess=function(e){t(e.target.result)},o.onerror=function(e){r("Database error:",e.target.errorCode)}})}async function i(e,t,r=[0]){function i(e,t,r){let o=e.closest('[sf="cascader"], label'),i=[o||e];i[0].querySelectorAll("*").forEach(e=>i.push(e)),i.forEach(e=>e.classList[r?"add":"remove"](a+t))}async function n(e){let t=await o(p),r=t.transaction(["files"],"readonly"),i=r.objectStore("files");return new Promise((r,o)=>{let n=i.get(e);n.onsuccess=()=>{t.close(),r(n.result)},n.onerror=()=>{t.close(),o(Error("Error retrieving file"))}})}await new Promise(e=>setTimeout(e,10));let l="sfp-swap-label-default-value",a=StudioForm.config.comboClassPrefix,s=StudioForm.config.eventPrefix,c=e.elements,d=c.mask,p="sfp-memory-js-"+e.name,f="true"==document.body.getAttribute("sfp-memory-local-storage")?localStorage:sessionStorage,u=[];d.querySelectorAll("input, textarea, select").forEach(e=>u.push(e));let h=u.map(async r=>{var o;let a=((function e(t,...r){let o=null;return r.every(e=>{let r=t.getAttribute(e);return!r||(o=r,!1)}),o})(o=r,"data-name","name","id","class","type")||o.tagName).replace(/[?&!'()*]/g,"_"),s=t[a],c=Array.isArray(s);if(!["radio","checkbox","file"].includes(r.type)){r.value=s||"",s&&r.dispatchEvent(new Event("input",{bubbles:!0})),s||i(r,"valid",!1);return}if("file"==r.type){if(!s){!function t(r,o){i(r,"attached",!1),r.removeAttribute("sf-attached"),delete e.data.files[o];let n=r.closest("label")?.querySelector('[sf="swap-label"]');n?.hasAttribute(l)&&(n.innerHTML=n.getAttribute(l)),r.value=""}(r,a);return}let p="__SFP_FILE__";if(!c&&s.startsWith(p)){let f=await n(s.replace(p,""));!function t(r,o,n){i(r,"attached",!0),r.setAttribute("sf-attached","");let a=r.closest("label")?.querySelector('[sf="swap-label"]');a&&(a.hasAttribute(l)||a.setAttribute(l,a.innerHTML),a.innerHTML=o.name),e.data.files[n]=o}(r,f.data,a)}}if("radio"==r.type){let u=r.value==s;r.checked=u,i(r,"checked",u)}if("checkbox"==r.type){let h=r.getAttribute("sf-value");if(!h){r.value=s||"",r.checked=!!r.value,i(r,"checked",r.checked);return}let g=d.querySelectorAll(`input[type="checkbox"][name="${r.name}"]`),b=!1,m=[];if(s&&(c?s:[s]).forEach(e=>{g.forEach(t=>{let r=t.getAttribute("sf-value");e==r&&(m.push(r),b=!0)})}),g.forEach(e=>{e.required=!b}),b||(r.value=""),m.includes(h)&&"Other"==h){r.click();return}m.includes(h)&&(r.value=h),r.checked=!!r.value,i(r,"checked",r.checked)}});e.record=r,await Promise.all(h),d.dispatchEvent(new CustomEvent("change")),d.dispatchEvent(new CustomEvent(s+"transition")),f.setItem(p,JSON.stringify(t))}function n(){StudioForm.forEach(e=>i(e,{}))}window.StudioForm=window.StudioForm||[],window.StudioForm.push(r);let l=document.createElement("div");l.id="studioFormDebugControls",l.style.cssText=`
position: fixed;
bottom: 20px;
right: 20px;
width: auto;
/* min-width: 515px; */
background-color: #2c2c2c;
border: 2px solid #555;
border-radius: 10px;
font-family: Arial, sans-serif;
font-size: 14px;
color: #fff;
display: flex;
align-items: stretch;
cursor: grab;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
z-index: 1000;
user-select: none;
`;let a=document.createElement("div");a.style.cssText=`
position: absolute;
top: -10px;
left: -10px;
width: 24px;
height: 24px;
cursor: pointer;
z-index: 1001;
`,a.innerHTML=`
<svg viewBox="0 0 24 24" width="24" height="24">
<circle cx="12" cy="12" r="10" stroke="#555" stroke-width="2" fill="#222"/>
<line x1="8" y1="8" x2="16" y2="16" stroke="#ddd" stroke-width="2" stroke-linecap="round"/>
<line x1="8" y1="16" x2="16" y2="8" stroke="#ddd" stroke-width="2" stroke-linecap="round"/>
</svg>
`,a.onclick=()=>{l.style.display="none"},l.appendChild(a);let s=document.createElement("img");s.src="https://assets-global.website-files.com/6572be9cbc50e968d34e0ea0/6572e4b79c13b90bc1affe18_Final%20Logo2.png",s.alt="StudioForm Logo",s.style.cssText=`
height: 24px;
width: 24px;
`;let c=document.createElement("a");c.href="https://www.StudioForm.pro",c.target="_blank",c.appendChild(s);let d=document.createElement("div");d.style.cssText=`
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
border-bottom-left-radius: 8px;
background-color: rgba(251, 79, 37, 0.1); /* Light background color based on the logo */
backdrop-filter: blur(8px); /* Same blur effect for consistency */
width: 56px; /* Uniform width with Chamber 2 */
`,d.appendChild(c),l.appendChild(d);let p=document.createElement("img");p.src="https://d3e54v103j8qbb.cloudfront.net/static/favicon_default.b10796b955.png",p.alt="Webflow Logo",p.style.cssText=`
height: 24px;
width: 24px;
`;let f=document.createElement("a");f.href="https://www.webflow.com",f.target="_blank",f.appendChild(p);let u=document.createElement("div");u.style.cssText=`
display: flex;
align-items: center;
justify-content: center;
border-left: 2px solid rgb(85, 85, 85);
background-color: rgba(0, 102, 255, 0.1); /* Light blue background based on logo color */
backdrop-filter: blur(8px); /* Subtle blur effect */
width: 58px; /* Uniform width for chambers 1, 2, 4, & 5 */
`,e&&(p.src="https://uploads-ssl.webflow.com/671a80027ac32417164a6026/6728ab2258ffc8edfb7f4590_wized-square-icon.svg",f.href="https://www.wized.com",u.style.backgroundColor="rgba(110, 48, 247, 0.1)"),u.appendChild(f),l.appendChild(u);let h=document.createElement("div");h.innerHTML=`
<div style="
font-size: 13px;
line-height: 15px;
font-family: 'Brush Script MT', 'Pacifico', cursive;
background: linear-gradient(45deg, rgb(251, 79, 37), #ff00cc, #3333ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 10px rgba(251, 79, 37, 0.6), 0 0 10px rgba(51, 51, 255, 0.6);
letter-spacing: 1px;
margin-bottom: 0px; /* Tighter margin for closer spacing */
">Debugger</div>
<div style="
font-size: 16px;
font-family: 'Impact', 'Futura', sans-serif;
font-weight: bold;
color: #ddd;
letter-spacing: 0.5px;
line-height: 20px;
">Memory Mode</div>
`;let g=document.createElement("div");g.style.cssText=`
padding: 8px 16px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-left: 2px solid rgb(85, 85, 85);
border-right: 2px solid rgb(85, 85, 85);
`,g.appendChild(h),l.appendChild(g);let b="true"===localStorage.getItem("debugMode"),m=!1,x=document.createElement("div");x.style.cssText=`
display: flex;
width: 58px; /* Keeping original width */
align-items: center;
justify-content: center;
cursor: pointer;
font-family: 'Impact', 'Futura', sans-serif; /* Updated font */
font-size: 16px;
font-weight: bold;
text-transform: uppercase;
color: white;
padding: 5px;
border-right: 2px solid rgb(85, 85, 85); /* Keeping original right border */
text-align: center;
position: relative; /* To position the shadow */
`;let y=()=>{m&&(x.innerText=b?"ON":"OFF",b?(x.style.color="transparent",x.style.backgroundClip="text",x.style.webkitBackgroundClip="text",x.style.backgroundImage="linear-gradient(to left, #4CAF50, #2ECC71)",x.style.boxShadow="inset 0 0 10px rgba(39, 174, 96, 0.8)"):(x.style.color="transparent",x.style.backgroundClip="text",x.style.webkitBackgroundClip="text",x.style.backgroundImage="linear-gradient(to left, #e74c3c, #c0392b)",x.style.boxShadow="inset 0 0 10px rgba(231, 76, 60, 0.8)"))};x.onclick=()=>{m&&(b=!b,localStorage.setItem("debugMode",b),y())},y(),l.appendChild(x);let $=document.createElement("button");$.innerHTML="↻",$.style.cssText=`
margin: 0;
padding: 5px;
background-color: #333;
border: 2px solid #888;
border-radius: 50%; /* Rounded button for a more retro look */
color: #FFF;
font-family: 'Courier New', monospace;
font-size: 20px; /* Larger, retro-style icon */
cursor: pointer;
width: 40px; /* Consistent with the width of the other chambers */
height: 40px;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); /* Shadow for a more old-school, retro feel */
transition: transform 0.2s ease, background-color 0.2s ease; /* Smooth transition for hover effects */
`,$.onmouseenter=()=>{$.style.transform="rotate(10deg)",$.style.backgroundColor="#444"},$.onmouseleave=()=>{$.style.transform="rotate(0deg)",$.style.backgroundColor="#333"},$.onclick=()=>{n()};let w=document.createElement("div");w.style.cssText=`
padding: 0; /* Remove any padding */
display: flex;
align-items: center;
justify-content: center;
width: 56px; /* Match the width of other chambers */
`,w.appendChild($),l.appendChild(w);let _=()=>{let e=document.createElement("div");e.style.cssText=`
box-shadow: rgba(0, 0, 0, 0.3) 0px 4px 8px;
border-radius: 50%;
`;let t=document.createElement("div");t.style.cssText=`
width: 24px;
height: 24px;
border: 2px solid rgb(136, 136, 136);
border-top: 2px solid #fff; /* Darker top border to create spinning contrast */
border-radius: 50%; /* Circular spinner for a retro feel */
animation: spin 1s linear infinite; /* Smooth spin animation */
background-color: transparent; /* No background, just the border effect */
`,e.appendChild(t),x.appendChild(e)},k=document.createElement("style");function v(e){let t=e.getBoundingClientRect(),r=window.innerWidth,o=window.innerHeight,i=t.left,n=t.top,l=r-.5*t.width,a=o-.5*t.height;t.right<.5*t.width&&(i=0),t.bottom<.5*t.height&&(n=0),t.left>l&&(i=l),t.top>a&&(n=a),e.style.left=i+"px",e.style.top=n+"px",e.style.bottom="auto",e.style.right="auto",sessionStorage.setItem("controlsPosition",JSON.stringify({left:i,top:n}))}k.innerText=`
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`,document.head.appendChild(k),window.StudioForm=window.StudioForm||[],window.StudioForm.push(()=>{m=!0,y()}),m||_(),document.body.appendChild(l);let E=JSON.parse(sessionStorage.getItem("controlsPosition"));E&&(l.style.left=E.left+"px",l.style.top=E.top+"px",l.style.bottom="auto",l.style.right="auto",v(l));let C=!1,S,T;l.addEventListener("mousedown",e=>{C=!0,l.style.cursor="grabbing",S=e.clientX-l.getBoundingClientRect().left,T=e.clientY-l.getBoundingClientRect().top}),document.addEventListener("mousemove",e=>{if(C){let t=e.clientX-S,r=e.clientY-T,o=window.innerWidth-.5*l.offsetWidth,i=window.innerHeight-.5*l.offsetHeight;l.style.left=Math.min(Math.max(-(.5*l.offsetWidth),t),o)+"px",l.style.top=Math.min(Math.max(-(.5*l.offsetHeight),r),i)+"px",l.style.bottom="auto",l.style.right="auto"}}),document.addEventListener("mouseup",()=>{if(C){C=!1,l.style.cursor="grab";let e=l.getBoundingClientRect();sessionStorage.setItem("controlsPosition",JSON.stringify({left:e.left,top:e.top}))}})})();