{"id":126,"date":"2026-02-13T23:55:49","date_gmt":"2026-02-13T23:55:49","guid":{"rendered":"https:\/\/www.relayed.net\/?post_type=tools&#038;p=126"},"modified":"2026-02-15T00:55:11","modified_gmt":"2026-02-15T00:55:11","slug":"swap-compare","status":"publish","type":"tools","link":"https:\/\/www.relayed.net\/?tools=swap-compare","title":{"rendered":"Swap + Compare"},"content":{"rendered":"\n <div class=\"pmsw-wrap\" data-pmsw id=\"pmsw_7b989ac2-284c-4f12-99ac-19c25314070b\"> <div class=\"pmsw-sec\"> <div class=\"pmsw-title\">Swap + \/ -<\/div>\n <textarea class=\"pmsw-in\" rows=\"2\" placeholder=\"Paste here...\"><\/textarea>\n <div class=\"pmsw-actions\"> <button type=\"button\" class=\"pmsw-btn\" data-pmsw-swap>Swap<\/button>\n <button type=\"button\" class=\"pmsw-btn pmsw-btn2\" data-pmsw-clear>Clear<\/button>\n <div class=\"pmsw-hit\" data-pmsw-hit>Swaps: <span data-pmsw-hitn>1202<\/span><\/div> <\/div>\n <pre class=\"pmsw-out\" data-pmsw-out><\/pre> <\/div> <div class=\"pmsw-sec pmsw-sec2\"> <div class=\"pmsw-title\">Compare A vs B<\/div>\n <div class=\"pmsw-grid\"> <div> <div class=\"pmsw-lab\">A<\/div>\n <textarea class=\"pmsw-in pmsw-ab\" rows=\"2\" placeholder=\"e.g. +2WL+2OC-2WI-AD-IE\" data-pmsw-a><\/textarea> <\/div>\n <div> <div class=\"pmsw-lab\">B<\/div> <textarea class=\"pmsw-in pmsw-ab\" rows=\"2\" placeholder=\"e.g. +2WL+2OC-2WI-AD\" data-pmsw-b><\/textarea> <\/div> <\/div>\n <div class=\"pmsw-actions\"> <button type=\"button\" class=\"pmsw-btn\" data-pmsw-compare>Compare<\/button>\n <button type=\"button\" class=\"pmsw-btn pmsw-btn2\" data-pmsw-clear2>Clear<\/button> <\/div>\n <div class=\"pmsw-comp\" data-pmsw-comp><\/div> <\/div> <\/div>\n\n <style>\n .pmsw-wrap{max-width:980px;border:1px solid #e3e5e8;border-radius:12px;padding:14px;margin:16px 0}\n .pmsw-sec{padding:6px 0}\n .pmsw-sec2{margin-top:10px;padding-top:14px;border-top:1px solid #eef0f2}\n .pmsw-title{font-size:14px;font-weight:700;margin-bottom:8px}\n .pmsw-lab{font-size:12px;font-weight:700;margin:0 0 6px 2px;opacity:.8}\n .pmsw-in{width:100%;padding:5px;border:1px solid #cfd4da;border-radius:10px;box-sizing:border-box;background:#131313;color:#FFFFFF}\n .pmsw-ab{min-height:64px}\n .pmsw-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px;align-items:center}\n .pmsw-btn{appearance:none;border:1px solid #cfd4da;background:#111;color:#fff;padding:8px 12px;border-radius:10px;cursor:pointer;font-size:13px}\n .pmsw-btn2{background:#fff;color:#111}\n .pmsw-hit{margin-left:auto;font-size:12px;opacity:.85;white-space:nowrap}\n .pmsw-out{margin-top:12px;white-space:pre-wrap;word-break:break-word;padding:10px;border:1px dashed #cfd4da;border-radius:10px;min-height:44px;}\n .pmsw-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n @media (max-width:720px){.pmsw-grid{grid-template-columns:1fr}.pmsw-hit{margin-left:0}}\n .pmsw-comp{margin-top:12px;border:1px dashed #cfd4da;border-radius:10px;padding:10px}\n .pmsw-comp .row{display:flex;gap:10px;align-items:flex-start;flex-wrap:wrap;margin:6px 0}\n .pmsw-comp .k{min-width:170px;font-weight:700}\n .pmsw-comp code{}\n <\/style>\n\n <script>\n (function(){ const root = document.getElementById(\"pmsw_7b989ac2-284c-4f12-99ac-19c25314070b\"); if(!root) return;\n const ajaxUrl = \"https:\\\/\\\/www.relayed.net\\\/wp-admin\\\/admin-ajax.php\";\n const inp = root.querySelector('.pmsw-in'); const out = root.querySelector('[data-pmsw-out]');\n const btnSwap = root.querySelector('[data-pmsw-swap]'); const btnClear = root.querySelector('[data-pmsw-clear]');\n const hitN = root.querySelector('[data-pmsw-hitn]'); function swapPlusMinus(s){ return String(s).replace(\/\\+\/g,'__P__').replace(\/-\/g,'+').replace(\/__P__\/g,'-'); }\n async function copyText(t){ t=String(t||''); if(!t) return false; try{ if(navigator.clipboard && window.isSecureContext){ await navigator.clipboard.writeText(t); return true; } }catch(e){}\n try{ var ta=document.createElement('textarea'); ta.value=t; ta.setAttribute('readonly',''); ta.style.position='fixed'; ta.style.left='0'; ta.style.top='0'; ta.style.opacity='0';\n document.body.appendChild(ta); ta.focus(); ta.select(); ta.setSelectionRange(0, ta.value.length);\n var ok=document.execCommand('copy'); document.body.removeChild(ta); return !!ok; }catch(e){ return false; } }\n function bumpHit(){ fetch(ajaxUrl,{method:'POST',headers:{'Content-Type':'application\/x-www-form-urlencoded; charset=UTF-8'},body:'action=pmsw_hit'})\n .then(r=>r.json()).then(j=>{ if(j&&j.success&&j.data&&typeof j.data.hits!=='undefined') hitN.textContent=String(j.data.hits); }).catch(()=>{}); }\n function toast(msg){var t=root.querySelector('[data-pmsw-toast]'); if(!t){ t=document.createElement('div'); t.setAttribute('data-pmsw-toast','');\n t.style.position='fixed'; t.style.right='16px'; t.style.bottom='16px'; t.style.zIndex='99999';\n t.style.background='#111'; t.style.color='#fff'; t.style.padding='10px 12px'; t.style.borderRadius='10px';\n t.style.fontSize='25px'; t.style.boxShadow='0 8px 24px rgba(0,0,0,.18)'; t.style.opacity='0'; t.style.transform='translateY(6px)';\n t.style.transition='opacity .18s ease, transform .18s ease'; document.body.appendChild(t); }t.textContent=msg; clearTimeout(t.__tm);\n requestAnimationFrame(()=>{ t.style.opacity='1'; t.style.transform='translateY(0)'; });\n t.__tm=setTimeout(()=>{ t.style.opacity='0'; t.style.transform='translateY(6px)'; }, 1200);}\n btnSwap.addEventListener('click', async function(){const v=inp.value||''; const res=swapPlusMinus(v); out.textContent=res; bumpHit();\n const ok=await copyText(res); if(ok) toast('Copied to clipboard'); else toast('Copy failed');});\n btnClear.addEventListener('click', function(){ inp.value=''; out.textContent=''; inp.focus(); });\n const aEl = root.querySelector('[data-pmsw-a]'); const bEl = root.querySelector('[data-pmsw-b]');\n const comp = root.querySelector('[data-pmsw-comp]'); const btnCmp = root.querySelector('[data-pmsw-compare]');const btnClear2 = root.querySelector('[data-pmsw-clear2]');\n function parsePM(s){ s=String(s||'').replace(\/\\s+\/g,''); const inc=new Set(); const exc=new Set(); const re=\/([+\\-])([A-Za-z0-9]{2,})\/g; let m;\n while((m=re.exec(s))!==null){ const sign=m[1]; const tok=m[2].toUpperCase(); if(sign==='+') inc.add(tok); else exc.add(tok); } return {inc,exc}; }\n function setToSortedArr(set){ return Array.from(set).sort(); }\n function diffSets(aSet,bSet){ const aOnly=new Set(); for(const x of aSet) if(!bSet.has(x)) aOnly.add(x);\n const bOnly=new Set(); for(const x of bSet) if(!aSet.has(x)) bOnly.add(x); return {aOnly,bOnly}; }\n function fmtList(arr){ if(!arr.length) return '<em>None<\/em>'; return '<code>' + arr.join(', ') + '<\/code>'; }\n btnCmp.addEventListener('click', function(){ const A=parsePM(aEl.value); const B=parsePM(bEl.value); const incDiff=diffSets(A.inc,B.inc); const excDiff=diffSets(A.exc,B.exc);\n const aIncOnly=setToSortedArr(incDiff.aOnly); const bIncOnly=setToSortedArr(incDiff.bOnly);\n const aExcOnly=setToSortedArr(excDiff.aOnly); const bExcOnly=setToSortedArr(excDiff.bOnly);\n comp.innerHTML=[ '<div class=\"row\"><div class=\"k\">Included in A only:<\/div><div>'+fmtList(aIncOnly)+'<\/div><\/div>',\n '<div class=\"row\"><div class=\"k\">Included in B only:<\/div><div>'+fmtList(bIncOnly)+'<\/div><\/div>',\n '<div class=\"row\"><div class=\"k\">Excluded in A only:<\/div><div>'+fmtList(aExcOnly)+'<\/div><\/div>',\n '<div class=\"row\"><div class=\"k\">Excluded in B only:<\/div><div>'+fmtList(bExcOnly)+'<\/div><\/div>', ].join(''); });\n btnClear2.addEventListener('click', function(){ aEl.value=''; bEl.value=''; comp.innerHTML=''; aEl.focus(); });})();\n <\/script> \n","protected":false},"author":1,"featured_media":139,"template":"","meta":{"org":"","name":"","type":"","content":""},"class_list":["post-126","tools","type-tools","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/www.relayed.net\/index.php?rest_route=\/wp\/v2\/tools\/126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.relayed.net\/index.php?rest_route=\/wp\/v2\/tools"}],"about":[{"href":"https:\/\/www.relayed.net\/index.php?rest_route=\/wp\/v2\/types\/tools"}],"author":[{"embeddable":true,"href":"https:\/\/www.relayed.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.relayed.net\/index.php?rest_route=\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/www.relayed.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}