-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.min.js
1 lines (1 loc) · 10.4 KB
/
script.min.js
1
let jobListingText="",resumeText="";const commonWords=["a","about","above","after","again","against","ain't","all","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","between","both","but","by","can't","cannot","could","couldn't","did","didn't","do","does","doesn't","doing","don't","down","during","each","few","for","from","further","had","hadn't","has","hasn't","have","haven't","having","he","he'd","he'll","he's","her","here","here's","hers","herself","him","himself","his","how","how's","i","i'd","i'll","i'm","i've","if","in","into","is","isn't","it","it's","its","itself","just","let's","ma'am","me","more","most","mustn't","my","myself","no","nor","not","o'clock","of","off","on","once","only","or","other","ought","our","ours","ourselves","out","over","own","re","s","shan't","she","she'd","she'll","she's","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","to","too","under","until","up","very","was","wasn't","we","we'd","we'll","we're","we've","were","weren't","what","what's","when","when's","where","where's","which","while","who","who's","whom","why","why's","with","won't","would","wouldn't","you","you'd","you'll","you're","you've","your","yours","yourself","yourselves","able","abst","accordance","according","accordingly","across","act","actually","added","adj","affected","affecting","affects","afterwards","ah","almost","alone","along","already","also","although","always","among","amongst","announce","another","anybody","anyhow","anymore","anyone","anything","anyway","anyways","anywhere","apparently","approximately","arent","arise","around","aside","ask","asking","auth","available","away","awfully","b","back","became","become","becomes","becoming","beforehand","begin","beginning","beginnings","begins","behind","believe","beside","besides","beyond","biol","brief","briefly","c","ca","came","cannot","can't","cause","causes","certain","certainly","co","com","come","comes","contain","containing","contains","couldnt","date","different","done","downwards","due","e","ed","edu","effect","eg","eight","eighty","either","else","elsewhere","end","ending","enough","especially","et","etc","even","ever","every","everybody","everyone","everything","everywhere","ex","except","f","far","ff","fifth","first","five","fix","followed","following","follows","former","formerly","forth","found","four","furthermore","g","gave","get","gets","getting","give","given","gives","giving","go","goes","gone","got","gotten","h","happens","hardly","hed","hence","hereafter","hereby","herein","heres","hereupon","hes","hi","hid","hither","home","howbeit","however","hundred","id","ie","im","immediate","immediately","importance","important","inc","indeed","index","information","instead","invention","inward","itd","it'll","j","k","kept","kg","km","know","known","knows","l","largely","last","lately","later","latter","latterly","least","less","lest","let","lets","like","liked","likely","line","little","look","looking","looks","ltd","made","mainly","make","makes","many","may","maybe","mean","means","meantime","meanwhile","merely","mg","might","million","miss","ml","moreover","mostly","mr","mrs","much","mug","must","n","na","name","namely","nay","nd","near","nearly","necessarily","necessary","need","needs","neither","never","nevertheless","new","next","nine","ninety","nobody","non","none","nonetheless","noone","normally","nos","noted","nothing","nowhere","obtain","obtained","obviously","often","oh","ok","okay","old","omitted","one","ones","onto","ord","others","otherwise","outside","overall","owing","p","page","pages","part","particular","particularly","past","per","perhaps","placed","please","plus","poorly","possible","possibly","potentially","pp","predominantly","present","previously","primarily","probably","promptly","proud","provides","put","q","que","quickly","quite","qv","r","ran","rather","rd","readily","really","recent","recently","ref","refs","regarding","regardless","regards","related","relatively","research","respectively","resulted","resulting","results","right","run","said","saw","say","saying","says","sec","section","see","seeing","seem","seemed","seeming","seems","seen","self","selves","sent","seven","several","shall","shed","shes","show","showed","shown","showns","shows","significant","significantly","similar","similarly","since","six","slightly","somebody","somehow","someone","somethan","something","sometime","sometimes","somewhat","somewhere","soon","sorry","specifically","specified","specify","specifying","still","stop","strongly","sub","substantially","successfully","sufficiently","suggest","sup","sure","take","taken","taking","tell","tends","th","thank","thanks","thanx","thats","that've","thence","thereafter","thereby","thered","therefore","therein","there'll","therere","theres","thereto","thereupon","there've","theyd","theyre","think","thou","though","thoughh","thousand","throug","throughout","thru","thus","til","tip","together","took","toward","towards","tried","tries","truly","try","trying","ts","twice","two","u","un","unfortunately","unless","unlike","unlikely","unto","upon","ups","us","use","used","useful","usefully","usefulness","uses","using","usually","v","value","various","'ve","via","viz","vol","vols","vs","w","want","wants","wasnt","way","wed","welcome","went","werent","whatever","what'll","whats","whence","whenever","whereafter","whereas","whereby","wherein","wheres","whereupon","wherever","whether","whim","whither","whod","whoever","whole","who'll","whomever","whos","whose","widely","willing","wish","within","without","wont","words","world","wouldnt","www","x","yes","yet","youd","youre","z","zero"];let deletedKeywords=[],sortedKeywords=[],resumeWords;function removePunctuation(word){return word.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()'"“”‘’]/g,"").replace(/"/g,"")}function updateMatchPercentage(){const jobListingWords=jobListingText.split(/\s+/).map(word=>removePunctuation(word));resumeWords=resumeText.split(/\s+/).map(word=>removePunctuation(word));const jobKeywords=jobListingWords.filter(word=>!commonWords.includes(word)),keywordFrequency={};jobKeywords.forEach(word=>{const frequency=resumeWords.filter(resumeWord=>resumeWord===word).length;keywordFrequency[word]=frequency});const totalKeywords=Object.keys(keywordFrequency).length,matchedKeywords=Object.values(keywordFrequency).filter(freq=>freq>0).length,matchPercentage=matchedKeywords/totalKeywords*100,matchMetric=document.getElementById("match-metric");matchMetric.textContent=`Total Match: ${matchPercentage.toFixed(2)}%`}function updateKeywords(){jobListingText=document.getElementById("job-listing-textbox").value.toLowerCase(),resumeText=document.getElementById("resume-textbox").value.toLowerCase();const jobListingWords=jobListingText.split(/\s+/).map(word=>removePunctuation(word)),resumeWords=resumeText.split(/\s+/).map(word=>removePunctuation(word)),jobKeywords=jobListingWords.filter(word=>!commonWords.includes(word)),keywordFrequency={};jobKeywords.forEach(word=>{const frequency=resumeWords.filter(resumeWord=>resumeWord===word).length;keywordFrequency[word]=frequency}),sortedKeywords=Object.keys(keywordFrequency).sort((a,b)=>keywordFrequency[b]-keywordFrequency[a]);const keywordList=document.getElementById("keyword-list");keywordList.innerHTML="",sortedKeywords.forEach((keyword,index)=>{const frequency=keywordFrequency[keyword],listItem=document.createElement("li"),deleteButton=document.createElement("button");deleteButton.textContent="x",deleteButton.classList.add("delete-button"),deleteButton.addEventListener("click",()=>{keywordList.removeChild(listItem),deletedKeywords.push({keyword:keyword,index:index}),updateMatchPercentage()}),listItem.textContent=`${index+1}. ${keyword} (${frequency}x)`,listItem.appendChild(deleteButton);const color=calculateColor(frequency);listItem.style.backgroundColor=color,keywordList.insertBefore(listItem,keywordList.firstChild)}),updateMatchPercentage()}function undoDeletion(sortedKeywords){if(deletedKeywords.length>0){const{keyword:keyword,index:index}=deletedKeywords.pop();sortedKeywords.splice(index,0,keyword);const keywordFrequency={};sortedKeywords.forEach(word=>{const frequency=resumeWords.filter(resumeWord=>resumeWord===word).length;keywordFrequency[word]=frequency});const keywordList=document.getElementById("keyword-list");keywordList.innerHTML="",sortedKeywords.forEach((sortedKeyword,newIndex)=>{const frequency=keywordFrequency[sortedKeyword];function createKeywordListItem(keyword,frequency,keywordList,sortedKeywords,newIndex){const listItem=document.createElement("li"),deleteButton=document.createElement("button");deleteButton.textContent="x",deleteButton.classList.add("delete-button"),deleteButton.addEventListener("click",()=>{keywordList.removeChild(listItem),deletedKeywords.push({keyword:keyword,index:index}),updateMatchPercentage()}),listItem.textContent=`${newIndex+1}. ${sortedKeyword} (${frequency}x)`,listItem.appendChild(deleteButton);const color=calculateColor(frequency);listItem.style.backgroundColor=color,keywordList.appendChild(listItem)}createKeywordListItem(sortedKeyword,frequency,keywordList,sortedKeywords,newIndex)}),updateMatchPercentage()}}function calculateColor(frequency){const maxFrequency=4,minRed=255,maxBlue=255,minBlue=0,clippedFrequency=Math.min(Math.max(frequency,0),4),redValue=255,blueValue=0+clippedFrequency/4*255;return`rgb(255, 0, ${blueValue})`}function saveSession(){localStorage.setItem("jobListingText",jobListingText),localStorage.setItem("resumeText",resumeText)}function restoreSession(){const savedJobListingText=localStorage.getItem("jobListingText"),savedResumeText=localStorage.getItem("resumeText");savedJobListingText&&savedResumeText&&(jobListingText=savedJobListingText,resumeText=savedResumeText,document.getElementById("job-listing-textbox").value=jobListingText,document.getElementById("resume-textbox").value=resumeText,updateKeywords(),updateMatchPercentage())}const jobListingTextbox=document.getElementById("job-listing-textbox");jobListingTextbox.addEventListener("input",()=>{updateKeywords(),updateMatchPercentage(),saveSession()});const resumeTextbox=document.getElementById("resume-textbox");resumeTextbox.addEventListener("input",()=>{updateKeywords(),updateMatchPercentage(),saveSession()});const restoreButton=document.getElementById("restore-button");restoreButton.addEventListener("click",()=>{restoreSession()});const undoButton=document.getElementById("undo-button");undoButton.addEventListener("click",()=>{undoDeletion(sortedKeywords)}),restoreSession();