You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncfunctionsleep(ms){returnnewPromise(resolve=>setTimeout(resolve,ms));}varnotyf=newNotyf({types: [{type: 'info',background: 'blue',icon: {className: 'material-icons',tagName: 'i',text: 'info'}},{type: 'warning',background: 'orange',icon: {className: 'material-icons',tagName: 'i',text: 'warning'}}]});// Function to show the success messagefunctionshowMessage(msgtype,msg){varshowMsg=document.getElementById("showMsg");// Check if the success message should be displayedif(showMsg.dataset.display!=='false'){// Use Notyf for displaying success messageif(msgtype=='success'){notyf.success({message: msg,duration: 9500,dismissible: true});}elseif(msgtype=='warn'){notyf.open({type: "warning",message: msg,duration: 9500,dismissible: true});}elseif(msgtype=='info'){notyf.open({type: "info",message: msg,duration: 9500,dismissible: true});}elseif(msgtype=='error'){notyf.error({message: msg,duration: 9500,dismissible: true});}}}functioncopyToClipboard(text){// Create a temporary input elementconsttempInput=document.createElement('input');tempInput.value=text;// Append the input element to the DOMdocument.body.appendChild(tempInput);// Select the text inside the input elementtempInput.select();tempInput.setSelectionRange(0,99999);// For mobile devices// Copy the selected text to the clipboarddocument.execCommand('copy');// Remove the temporary input element from the DOMdocument.body.removeChild(tempInput);// Show a notification or perform any other action if neededshowMessage('success','Joke have been automatically copied to your clipboard!');//showMessage('warn', 'Joke copied to clipboard!');//showMessage('info', 'Joke copied to clipboard!');//showMessage('error', 'Joke copied to clipboard!');}asyncfunctionshowJoke(joke){console.log(joke);varjokeElement=document.getElementById('joke');jokeElement.innerHTML=joke;}// Add this function to your existing JavaScript fileasyncfunctionhandleButtonClick(type,message,joke){functionshowMsg(){showMessage(type,message);}showMsg();//showJoke(joke);try{// Fetch a new joke from the serverconstresponse=awaitfetch('/joke');if(!response.ok){thrownewError('Failed to fetch new joke');}// Parse the response text (assuming it's a plain string)constnewJoke=awaitresponse.text();copyToClipboard(newJoke);// Run showJoke() with the new jokeshowJoke(newJoke);}catch(error){console.error('Error fetching or processing new joke:',error);}}
The text was updated successfully, but these errors were encountered:
Full Error:
I have it included in the html file:
Javascript:
The text was updated successfully, but these errors were encountered: