',e.onclick=e=>{document.getElementById("imgEditDiv").textContent="edited";var t=null;(t=("IMG"===e.target.tagName?e.target.parentElement:e.target).parentElement.previousSibling.getElementsByTagName("img")[0]).src.includes("http")?document.getElementById("imageUrl").value=t.src:((e=document.getElementById("previewUploadedImage")).style.display="block",e.src=t.src),document.getElementById("imageCaption").value=i.textContent,document.getElementById("imageAlt").value=t.alt,document.getElementById("imageBtn").click()},document.createElement("button")),m=(d.className="editorBtn shadow",d.innerHTML='',d.onclick=()=>{o.remove(),window.imgDivToEdit=null},l.name="imgBtnDiv",l.append(e),l.append(d),o.append(a),o.append(l),document.getElementsByClassName("contentToEdit")[0]);return null!==window.imgDivToEdit?(window.imgDivToEdit.getElementsByTagName("figure")[0].remove(),window.imgDivToEdit.prepend(a)):(e=lastFocus.tagName,["H1","H2","H3","H4","LI","P","DIV"].includes(e)?"DIV"===e&&null!==lastFocus.querySelector("FIGURE")?(m.insertBefore(o,lastFocus.nextElementSibling),"edited"===document.getElementById("imgEditDiv").textContent&&(lastFocus.remove(),lastFocus=null,o.click())):"LI"===e?m.insertBefore(o,lastFocus.parentElement.parentElement.nextElementSibling):m.insertBefore(o,lastFocus.parentElement.nextElementSibling):document.getElementsByClassName("contentToEdit")[0].append(o)),document.getElementById("closeImageModale").click(),m.dispatchEvent(new KeyboardEvent("keydown",{key:"Alt"})),o};function preview_image(e){var t=document.getElementById("previewUploadedImage");document.getElementById("previewUploadedImage").style.display="block",t.src=URL.createObjectURL(e.target.files[0])}document.getElementById("addImageFromUpload").onclick=e=>{addImageToEditor(document.getElementById("previewUploadedImage").src,e,imgDivToEdit)},document.getElementById("addImageFromUrl").onclick=e=>{addImageToEditor(document.getElementById("imageUrl").value,e,imgDivToEdit)},download64=(e,t)=>{var n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)};const getBase64FromUrl=async e=>{let n=await(await fetch(e)).blob();return new Promise(e=>{let t=new FileReader;t.readAsDataURL(n),t.onloadend=()=>{e(t.result)}})},showModale=(document.getElementById("uploadImage").onchange=()=>{preview_image(event)},e=>{document.getElementById(e).style.display="flex",document.getElementsByTagName("HTML")[0].style.overflowY="hidden"}),hideModale=e=>{document.getElementById(e).style.display="none",document.getElementsByTagName("HTML")[0].style.overflowY="auto"};document.getElementById("imageBtn").onclick=()=>{showModale("imgModale"),window.imgDivToEdit=null},document.getElementById("closeImageModale").onclick=()=>{hideModale("imgModale"),document.getElementById("previewUploadedImage").style.display="none",document.getElementById("previewUploadedImage").src="",document.getElementById("imageCaption").value="",document.getElementById("imageAlt").value="",document.getElementById("imgEditDiv").textContent=""};var actualPage=1;async function toDataURL(e){e=await fetch(e).then(e=>e.blob());return URL.createObjectURL(e)}async function download(e,t){var n=document.createElement("a");n.href=await toDataURL(t),n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}const createImage=(e,t,n)=>{let l=e+".jpg",o=n,a=t,d=document.createElement("div");d.className="flexRow height160px width160px padding5px borderRadius11px marginRight20px marginTop20px";e=document.createElement("div");e.className="shadow width100Perc flexRow spacebetween borderRadius13px",e.style.background=`url("${a}") center center / cover no-repeat`;let m=document.createElement("button"),i=(m.className="btn shadow borderRadius7px marginLeft5px backgroundBlack",m.style.display="none",m.innerHTML="",m.onclick=()=>{download(l,a)},document.createElement("button")),c=(i.className="btn shadow borderRadius7px marginRight5px backgroundBlack",i.innerHTML="",i.style.display="none",i.onclick=async e=>{showSpinner("pixaSpinner"),addImageToEditor(a,e,imgDivToEdit),hideSpinner("pixaSpinner")},document.createElement("button"));return c.className="btn shadow borderRadius7px marginRight5px backgroundBlack",c.innerHTML="",c.style.display="none",c.onclick=()=>{document.getElementById("devImage").src=a,document.getElementById("imageModale").style.display="flex",document.getElementById("imgDiv").scrollIntoView(),document.getElementsByTagName("HTML").style.overflowY="hidden"},e.onmouseover=()=>{m.style.display="block",i.style.display="block",c.style.display="block"},e.onmouseleave=()=>{m.style.display="none",i.style.display="none",c.style.display="none"},e.append(m),e.append(i),e.prepend(c),d.append(e),document.getElementById("imagesDiv").prepend(d),{preview:o,web:a}},showSpinner=(document.getElementById("closeImage").onclick=()=>{document.getElementById("devImage").src="",document.getElementById("imageModale").style.display="none",document.getElementsByTagName("HTML").style.overflowY="auto"},e=>{document.getElementById(e).style.display="inline-block"}),hideSpinner=e=>{document.getElementById(e).style.display="none"};var objectUrls=[];const getPixa=e=>{var t=document.getElementById("pixaPrompt").value,e="/get-pixabay-image?"+new URLSearchParams({perPage:16,page:e,prompt:t});showSpinner("pixaSpinner"),fetch(e).then(e=>e.text()).then(e=>{var t=JSON.parse(e);document.getElementById("imagesDiv").innerHTML="";for(var n=0;n{getPixa(actualPage=1)},document.getElementById("nextPixaPage").onclick=()=>{getPixa(++actualPage)},document.getElementById("previousPixaPage").onclick=()=>{0==--actualPage?actualPage=1:getPixa(actualPage)};var lastSelection=null;document.getElementById("deselectBtn").onclick=()=>{lastSelection=null},document.getElementsByClassName("contentToEdit")[0].onclick=()=>{var e=document.activeElement;event.target===document.getElementsByClassName("contentToEdit")[0]?lastSelection=null:document.getElementsByClassName("contentToEdit")[0].contains(e)&&!["IMG","BUTTON"].includes(e.tagName)&&(lastFocus=e,"FONT"===event.target.tagName)&&(e=parseInt(event.target.style.fontSize.replace("px","").trim()),document.getElementById("fontsize").value=e,lastSelection=null)};const getActiveElt=e=>{var t,n=lastFocus,l=document.getElementsByClassName("contentToEdit")[0];return l.contains(n)?"LI"===(t=n.tagName)&&"LI"===e?n:("LI"===t&&"LI"!==e?n.parentElement:n).parentElement:l.lastElementChild},insertAfter=(e,t)=>{null===t?document.getElementsByClassName("contentToEdit")[0].append(e):(t.focus(),"LI"===t.tagName?t.parentElement.append(e):null!==t.nextElementSibling?t.parentElement.insertBefore(e,t.nextElementSibling):document.getElementsByClassName("contentToEdit")[0].append(e))},addNew=(e,t,n)=>{let l=document.createElement(e);var o;return l.addEventListener("paste",e=>{e.preventDefault();var e=(e.clipboardData||window.clipboardData).getData("text"),t=window.getSelection();t.rangeCount&&(t.deleteFromDocument(),t.getRangeAt(0).insertNode(document.createTextNode(e)))}),l.setAttribute("contenteditable",n),l.onfocus=()=>{lastFocus=l},"LI"!==e?"UL"!==e&&"OL"!==e?(l.textContent=t,(n=document.createElement("div")).className="relative",n.append(l),(o=document.createElement("div")).className="tagName1",o.textContent=e,n.append(o),null!==(o=getActiveElt(e))?""===o.getElementsByTagName("*")[0].textContent.trim()&&0===o.getElementsByTagName("figure").length?o.outerHTML=n.outerHTML:insertAfter(n,getActiveElt(e)):document.getElementsByClassName("contentToEdit")[0].append(n)):((o=document.createElement("div")).className="relative",o.append(l),(n=document.createElement("LI")).setAttribute("contenteditable",!0),n.textContent=t,l.append(n),l.focus(),(n=document.createElement("div")).className="tagName1",n.textContent=e,o.append(n),null!==(n=getActiveElt(e))?""===n.textContent&&0===n.getElementsByTagName("figure").length?(replaceElt(o,n),n.outerHTML=o.outerHTML):insertAfter(o,getActiveElt(e)):document.getElementsByClassName("contentToEdit")[0].append(o)):(l.textContent=t,insertAfter(l,getActiveElt(e))),l.focus(),l.innerHTML=l.innerHTML.replace("
",""),lastFocus=l},noSelection=()=>""==window.getSelection().toString(),selectedText=()=>window.getSelection().toString();document.onkeydown=e=>{var t;document.getElementsByClassName("contentToEdit")[0].contains(e.target)&&"INPUT"!==e.target.tagName&&(t=e.keyCode||e.which,13==e.keyCode&&e.shiftKey||(13==t&&document.getElementsByClassName("contentToEdit")[0].contains(e.target)?"LI"===e.target.tagName?""===e.target.textContent?(e.preventDefault(),e.stopPropagation(),e.target.remove(),addNew("P","",!0)):(e.preventDefault(),e.stopPropagation(),addNew("LI","",!0)):(e.preventDefault(),e.stopPropagation(),addNew("P","",!0)):8==t&&""===e.target.textContent&&("LI"===e.target.tagName?1===e.target.parentElement.getElementsByTagName("li").length?(null!==e.target.parentElement.parentElement.previousSibling&&0===e.target.parentElement.parentElement.previousSibling.getElementsByTagName("img").length&&e.target.parentElement.parentElement.previousSibling.getElementsByTagName("*")[0].focus(),e.target.parentElement.parentElement):(null!==e.target.parentElement.parentElement.previousSibling&&0===e.target.parentElement.parentElement.previousSibling.getElementsByTagName("img").length&&(e.target.parentElement.parentElement.previousSibling.focus(),0===e.target.parentElement.parentElement.previousSibling.getElementsByTagName("img").length)&&(document.execCommand("selectAll",!1,null),document.getSelection().collapseToEnd()),e.target):(null!==e.target.parentElement.previousSibling&&(e.target.parentElement.previousSibling.getElementsByTagName("*")[0].focus(),0===e.target.parentElement.previousSibling.getElementsByTagName("img").length)&&(document.execCommand("selectAll",!1,null),document.getSelection().collapseToEnd()),e.target.parentElement)).remove()))};let arr1=["h1Btn","h2Btn","h3Btn","h4Btn","pBtn"];for(var i=0;i{var t,n,e=e.currentTarget.id.replace("Btn","").toUpperCase();noSelection()?addNew(e," ",!0):(t=selectedText(),(n=window.getSelection().anchorNode.parentElement).textContent===t?window.getSelection().anchorNode.parentElement.parentElement.remove():window.getSelection().anchorNode.parentElement.innerHTML=n.innerHTML.replace("
","").replace(t,""),addNew(e,t,!0))};let arr2=["olBtn","ulBtn"];for(i=0;i{var t,n,e=e.currentTarget.id.replace("Btn","").toUpperCase();noSelection()?addNew(e," ",!1):(t=selectedText(),(n=window.getSelection().anchorNode.parentElement).textContent===t?window.getSelection().anchorNode.parentElement.parentElement.remove():window.getSelection().anchorNode.parentElement.innerHTML=n.innerHTML.replace("
","").replace(t,""),addNew(e,t,!0))};var arr=["boldBtn","underlineBtn","italicBtn","strikethroughBtn","ulBtn","olBtn","linkBtn","imageBtn"];function changeFont(e){var t;null===lastSelection||isNaN(parseInt(e))||(selectElementContents(lastSelection),document.execCommand("fontSize",!1,"2"),(t=lastSelection.parentNode).removeAttribute("size"),t.style.fontSize=e+"px")}function getFontValue(e){}document.getElementById("boldBtn").onclick=e=>{document.execCommand("bold",!1,null)},document.getElementById("underlineBtn").onclick=e=>{document.execCommand("underline",!1,null)},document.getElementById("italicBtn").onclick=e=>{document.execCommand("italic",!1,null)},document.getElementById("strikethroughBtn").onclick=e=>{document.execCommand("strikethrough",!1,null)};var interval1=null;function selectElementContents(e,t){var n,l;window.getSelection&&document.createRange&&(n=window.getSelection(),(l=document.createRange()).selectNodeContents(e),n.removeAllRanges(),n.addRange(l))}document.getElementById("increaseFont").onmousedown=()=>{interval1=setInterval(()=>{let e=document.getElementById("fontsize").value;isNaN(parseInt(e))||(0==++e&&(e=1),changeFont(document.getElementById("fontsize").value=e))},100)},document.getElementById("increaseFont").onmouseup=()=>{clearInterval(interval1)},document.getElementById("increaseFont").ondrag=()=>{clearInterval(interval1)},document.getElementById("decreaseFont").onmousedown=()=>{interval1=setInterval(()=>{let e=document.getElementById("fontsize").value;isNaN(parseInt(e))||(0==--e&&(e=1),changeFont(document.getElementById("fontsize").value=e))},100)},document.getElementById("decreaseFont").onmouseup=()=>{clearInterval(interval1)},document.getElementById("decreaseFont").ondrag=()=>{clearInterval(interval1)},document.getElementById("fontsize").oninput=()=>{var e=document.getElementById("fontsize").value;isNaN(parseInt(e))||changeFont(e)},document.getElementById("linkBtn").onclick=()=>{document.getElementById("linkDiv").style.display="flex",lastSelection=window.getSelection()},document.getElementById("closeLinkBtn").onclick=()=>{document.getElementById("linkDiv").style.display="none"},document.getElementById("addLink").onclick=()=>{var e=document.getSelection().anchorNode,t=document.getElementById("link").value;null!==e?document.execCommand("CreateLink",!1,t):alert("No selection!")},document.getElementById("removeLink").onclick=()=>{null!==getSelection().anchorNode?document.execCommand("unlink",!1,!1):alert("No selection!")};const moveUp=()=>{var e,t=lastFocus.tagName;try{["H1","H2","H3","H4","LI","P"].includes(t)&&(e=document.querySelector(".contentToEdit"),"LI"!==t?e.insertBefore(lastFocus.parentElement,lastFocus.parentElement.previousElementSibling):e.insertBefore(lastFocus.parentElement.parentElement,lastFocus.parentElement.parentElement.previousElementSibling))}catch(e){alert("Up position limit reached")}},moveDown=(document.getElementById("moveUpBtn").onclick=()=>{moveUp()},()=>{var e,t=lastFocus.tagName;try{["H1","H2","H3","H4","LI","P"].includes(t)&&(e=document.querySelector(".contentToEdit"),"LI"!==t?e.insertBefore(lastFocus.parentElement,lastFocus.parentElement.nextElementSibling.nextElementSibling):e.insertBefore(lastFocus.parentElement.parentElement,lastFocus.parentElement.parentElement.nextElementSibling.nextElementSibling))}catch(e){alert("Down position limit reached!")}});document.getElementById("moveDownBtn").onclick=()=>{moveDown()},document.getElementsByClassName("contentToEdit")[0].onmouseup=()=>{var e=document.getSelection().anchorNode;document.getElementsByClassName("contentToEdit")[0].contains(e)&&"A"===(e=(lastSelection=e).parentElement).tagName&&(document.getElementById("link").value=e.href)},document.getElementById("closePalette").onclick=()=>{document.getElementById("colorPalette").style.display="none"},document.getElementById("colorBtn").onclick=()=>{document.getElementById("colorPalette").style.display="flex"};let colors1=["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#c0392b","#bdc3c7","#7f8c8d","#000000"];function clearSelection(){window.getSelection?window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}for(i=0;i{document.execCommand("styleWithCSS",!1,!0),document.execCommand("foreColor",!1,event.target.id),clearSelection()};const cleanCache=()=>{localStorage.clear(),location.reload()};function mediaFunc1(e){e.matches?(document.getElementById("leftPanelRecom").style.display="none",document.getElementById("leftPanelRecom").classList.add("leftAb"),document.getElementById("mbMenu").style.display="flex"):(document.getElementById("leftPanelRecom").classList.remove("leftAb"),document.getElementById("leftPanelRecom").style.display="flex",document.getElementById("mbMenu").style.display="none")}document.getElementById("cleanBtn1").onclick=()=>{cleanCache()},document.getElementById("closeFileModale").onclick=()=>{document.getElementById("importModale").style.display="none",document.getElementById("labelImportEditor").style.display="none",document.getElementById("labelImportEditorGuideline").style.display="none"},document.getElementById("fromHtmlUrl").onclick=()=>{document.getElementById("fileImport1").style.display="none",document.getElementById("urlImport1").style.display="block"},document.getElementById("fromHtmlFile").onclick=()=>{document.getElementById("fileImport1").style.display="block",document.getElementById("urlImport1").style.display="none"},document.getElementById("importBtn1Editor").onclick=()=>{""===document.getElementById("dataRecom").textContent.trim()?alert("There's no optimization!"):(document.getElementById("importModale").style.display="flex",document.getElementById("labelImportEditor").style.display="block",document.getElementById("labelImportEditorGuideline").style.display="none",document.getElementById("importBtn1SaveEditor").style.display="block",document.getElementById("importBtn1SaveEditorGuideline").style.display="none",document.getElementById("fileEditorImport1").setAttribute("accept",".editor"),document.getElementById("fromEditorFile").nextElementSibling.textContent="*.editor",document.getElementById("fromHtmlUrl").parentElement.style.display="flex",document.getElementById("fromHtmlFile").parentElement.style.display="flex")},document.getElementById("importBtn1EditorGuideline").onclick=()=>{document.getElementById("importModale").style.display="flex",document.getElementById("labelImportEditor").style.display="none",document.getElementById("labelImportEditorGuideline").style.display="block",document.getElementById("importBtn1SaveEditor").style.display="none",document.getElementById("importBtn1SaveEditorGuideline").style.display="block",document.getElementById("fileEditorImport1").setAttribute("accept",".fss"),document.getElementById("fromEditorFile").nextElementSibling.textContent="*.fss",document.getElementById("fromHtmlUrl").parentElement.style.display="none",document.getElementById("fromHtmlFile").parentElement.style.display="none",document.getElementById("fromEditorFile").click()},document.getElementById("fromHtmlUrl").onclick=()=>{document.getElementById("urlImport1").style.display="block",document.getElementById("fileImport1").style.display="none",document.getElementById("fileEditorImport1").style.display="none"},document.getElementById("fromHtmlFile").onclick=()=>{document.getElementById("urlImport1").style.display="none",document.getElementById("fileImport1").style.display="block",document.getElementById("fileEditorImport1").style.display="none"},document.getElementById("fromEditorFile").onclick=()=>{document.getElementById("urlImport1").style.display="none",document.getElementById("fileImport1").style.display="none",document.getElementById("fileEditorImport1").style.display="block"};var xc1=window.matchMedia("(max-width: 800px)");mediaFunc1(xc1),xc1.addListener(mediaFunc1),document.getElementById("guidelinesBtn").onclick=()=>{document.getElementById("leftPanelRecom").style.display="flex",document.getElementById("guidelinesBtn").style.display="none",document.getElementById("guidelinesLeftBtn").style.display="flex"},document.getElementById("guidelinesLeftBtn").onclick=()=>{document.getElementById("leftPanelRecom").style.display="none",document.getElementById("guidelinesBtn").style.display="flex",document.getElementById("guidelinesLeftBtn").style.display="none"},document.getElementById("fileToggle").onclick=()=>{document.getElementById("fileToggle").checked?(document.getElementById("fileInput").style.display="block",!0===document.getElementById("urlToggle").checked&&document.getElementById("urlToggle").click()):document.getElementById("fileInput").style.display="none"};const readFile=async e=>{var e=document.getElementById(e).files;return 0===e.length?(alert("Please upload a file!"),null):""===(e=await e[0].text()).trim()?(alert("The file is empty!"),null):e};function htmlDecode(e){return(new DOMParser).parseFromString(e,"text/html").documentElement}document.getElementById("urlToggle").onclick=()=>{document.getElementById("urlToggle").checked?(document.getElementById("urlInput").style.display="block",!0===document.getElementById("fileToggle").checked&&document.getElementById("fileToggle").click()):document.getElementById("urlInput").style.display="none"};const htmlToEditor=async e=>{var t=document.createElement("div"),n=(t.innerHTML=e,["H1","H2","H3","H4","P","IMG","UL","OL"]),l=t.children;document.querySelector(".contentToEdit").innerHTML="",null!==document.querySelector(".contentToEdit").lastChild&&document.querySelector(".contentToEdit").lastChild.focus();for(var o,a=0;a{10===(null!==localStorage.getItem("jobs")?JSON.parse(localStorage.getItem("jobs")):[]).length&&alert("You need to clear some of the saved jobs before you can continue, because you've reached the maximum of 10 saved jobs!\n If you face an issue, you may need to clear your cache ( Control + Shift + Delete )")},exportJobToFile=()=>{},populateResult=e=>{document.getElementById("recomLeft").outerHTML=e.html,document.getElementById("leftKeywords").innerHTML=`Optimizing for: "${e.job.keywords}"`,htmlToEditor(e.job.article),document.getElementById("dataRecom").textContent=e.job.data},setNlpModaleEvents=()=>{document.getElementById("closeNLPModale").onclick=()=>{document.getElementById("nlpModale").style.display="none"},document.getElementById("nlpInfoBtn").onclick=()=>{document.getElementById("nlpModale").style.display="flex"}},refreshEvents=()=>{createMore(),document.getElementById("searchWords").oninput=()=>{createSearch()},setNlpModaleEvents()},onRefresh=()=>{var e=localStorage.getItem("actualJob");null!==e&&(populateResult(JSON.parse(e)),setNlpModaleEvents(),refreshEvents())},getFreeSurferSeo=(onRefresh(),async(e,t)=>{let n=document.getElementById("urlToggle").checked,l=document.getElementById("urlInput").value,o=document.getElementById("fileToggle").checked,a=null;!0===o&&(a=await readFile("fileInput"));var d=(new Date).toLocaleString(),t={token:t,urlToggle:n,urlInput:l,fileToggle:o,fileInput:a,daToggle:"",daInput:"",input:e,dateTime:d};document.getElementById("spinner").style.display="block",document.getElementsByClassName("pBarre")[0].style.display="block",document.getElementById("prog").textContent="Processing your request...",document.getElementsByClassName("pBarre")[0].getElementsByTagName("div")[0].style.width="0";let m=document.getElementsByClassName("pBarre")[0].getElementsByTagName("div")[0];var i=setInterval(()=>{let e=parseInt(document.getElementsByClassName("pBarre")[0].getElementsByTagName("div")[0].style.width.replace("%",""));(e=isNaN(e)?10:e)<90&&(document.getElementsByClassName("pBarre")[0].getElementsByTagName("div")[0].style.width=e+10+"%")},4e3),c=setTimeout(()=>{document.getElementById("prog").textContent="Analyzing keywords..."},1e4),r=setTimeout(()=>{document.getElementById("prog").textContent="Processing..."},17e3),s=setTimeout(()=>{document.getElementById("prog").textContent="Getting your result..."},2e4);await fetch("/FSS",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(e=>e.text()).then(e=>{e=JSON.parse(e);populateResult(e),localStorage.setItem("actualJob",JSON.stringify(e)),clearInterval(i),clearTimeout(c),clearTimeout(r),clearTimeout(s),document.getElementById("spinner").style.display="none",document.getElementsByClassName("pBarre")[0].style.display="none",document.getElementById("prog").textContent="",document.getElementsByClassName("pBarre")[0].getElementsByTagName("div")[0].style.width="0%",m.width="0",refreshEvents()}).catch(e=>{console.log(e),alert("Something is wrong! Please check your internet connection before you continue..."),clearInterval(i),clearTimeout(c),clearTimeout(r),clearTimeout(s),document.getElementById("spinner").style.display="none",document.getElementsByClassName("pBarre")[0].style.display="none",document.getElementById("prog").textContent="",document.getElementsByClassName("pBarre")[0].getElementsByTagName("div")[0].style.width="0%",m.width="0"})}),showScore=e=>{var t=document.querySelector(".scoreNeedle"),e=(document.getElementById("score").textContent=e,Math.ceil(229*e/100+13));t.style.left=e+"px"};var tm=null;const editorToHtml=()=>{var e=["H1","H2","H3","H4","UL","OL","P","figure"],t=document.getElementsByClassName("contentToEdit")[0],n=document.createElement("div");n.innerHTML=t.innerHTML,n.querySelectorAll("*");let l="";for(var o=0;o{var e=["H1","H2","H3","H4","Hl","Hl","A","P"],t=document.getElementsByClassName("contentToEdit")[0],n=document.createElement("div");n.innerHTML=t.innerHTML,n.querySelectorAll("*");for(var l=0;l{clearTimeout(tm),tm=setTimeout(()=>{showSpinner("spinnerUpdate");let d=null!==document.getElementById("moreElt")?document.getElementById("moreElt").style.display:"none",e={editor:editorToHtml(),data:document.getElementById("dataRecom").textContent};fetch("/UFSS",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}).then(e=>e.text()).then(e=>{try{var t=JSON.parse(e),n=t.html,l=t.data,o=(document.getElementById("recomLeft").outerHTML=n,JSON.parse(localStorage.getItem("actualJob"))),a=(document.getElementById("leftKeywords").innerHTML=`Optimizing for: "${o.job.keywords}"`,document.getElementById("dataRecom").textContent=l,refreshEvents(),document.getElementById("moreElt").style.display=d,JSON.parse(localStorage.getItem("actualJob")));a.html=n,a.job.data=l,a.job.article=editorToHtml(),localStorage.setItem("actualJob",JSON.stringify(a)),hideSpinner("spinnerUpdate")}catch(e){console.log(e),alert("An unexpected error occured! Please try again..."),hideSpinner("spinnerUpdate")}})},e)};var mouseDown=!1;document.getElementsByClassName("contentToEdit")[0].onmousedown=()=>{""===document.getElementById("dataRecom").textContent.trim()||mouseDown||(updateRecom(3e3),mouseDown=!0)},document.getElementsByClassName("contentToEdit")[0].onkeydown=()=>{""!==document.getElementById("dataRecom").textContent.trim()&&(updateRecom(3e3),mouseDown=!1)},document.getElementById("getRecommandations").onclick=async()=>{""===document.getElementById("keywords").value.trim()||document.getElementById("keywords").value.trim().length<=2?alert("Please insert your query!"):(await getFreeSurferSeo(document.getElementById("keywords").value,""),await updateRecom(50))};const showHide=(e,t)=>{e=document.getElementById(e),t=document.getElementById(t).getElementsByTagName("img")[0];"none"===e.style.display?(e.style.display="flex",t.style.transform="rotate(90deg)"):(e.style.display="none",t.style.transform="rotate(0deg)")},isUrl=e=>{try{return Boolean(new URL(e))}catch(e){return!1}},importHtmlToEditor=async()=>{let e="";if(!0===document.getElementById("fromHtmlUrl").checked){var t=document.getElementById("urlImport1").value;if(""===t.trim()||!isUrl(t))return void alert("Not a valid URL! Try to paste the whole URL");try{document.getElementById("spinnerImport").style.display="block",e=await(await fetch("/pro",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({type:"url",content:t})})).text(),document.getElementById("spinnerImport").style.display="none"}catch(e){console.log(e),alert("Unexpected error, please check your URL and check your internet connection")}}else{t={type:"html",content:e=await readFile("fileImport1")};document.getElementById("spinnerImport").style.display="block",e=await(await fetch("/pro",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})).text(),document.getElementById("spinnerImport").style.display="none"}document.getElementById("importModale").style.display="none",htmlToEditor(e)},createFile=(e,t)=>{var n=document.createElement("a"),l=(new Date).toJSON().slice(0,10),o=(new Date).toJSON().slice(11,19).replace(":","h").replace(":","m").replace(":","s"),l=(n.download=l+` ${o}.`+t,new Blob([e],{type:"text/plain"})),o=window.URL.createObjectURL(l);n.href=o,n.click(),window.URL.revokeObjectURL(o)},saveEditorToFile=()=>{var e=editorToHtml();createFile(e,"editor")},saveEditorToHtml=()=>{var e=editorToHtml();createFile(e,"html")},saveEditorGuidelineToFile=()=>{""===document.getElementById("dataRecom").textContent.trim()?alert("There's no guidelines in the editor!"):createFile(localStorage.getItem("actualJob"),"fss")};document.getElementById("saveBtn1EditorToFile").onclick=async()=>{saveEditorToFile()},document.getElementById("saveBtn1EditorToHtml").onclick=async()=>{saveEditorToHtml()},document.getElementById("saveBtn1EditorGuidelineToFile").onclick=async()=>{saveEditorGuidelineToFile()},document.getElementById("importBtn1SaveEditor").onclick=async()=>{var e;!0===document.getElementById("fromEditorFile").checked?(showSpinner("spinnerImport"),null!==(e=await readFile("fileEditorImport1"))&&htmlToEditor(e)):(showSpinner("spinnerImport"),await importHtmlToEditor()),hideSpinner("spinnerImport")},document.getElementById("importBtn1SaveEditorGuideline").onclick=async()=>{var e,t;!0===document.getElementById("fromEditorFile").checked?(showSpinner("spinnerImport"),null!==(e=await readFile("fileEditorImport1"))&&(t=JSON.parse(e),htmlToEditor(t.job.article),t=t.job.data,document.getElementById("dataRecom").textContent=t,localStorage.setItem("actualJob",e),await updateRecom())):(showSpinner("spinnerImport"),await importHtmlToEditor(),0