Skip to content

Commit

Permalink
jsam: textarea-input error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ponali committed Jan 14, 2024
1 parent 24ec173 commit 2178f6f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion files/jsart/demos/textarea-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
@Ponali - replace input element with textarea for multiple line support
please make sure to use this with JSArt browser.
*/
let inel=document.querySelector("input#formula");let txel=document.createElement("textarea");txel.setAttribute("id","formula");txel.value=inel.value;txel.style.fontFamily="monospace";inel.parentNode.replaceChild(txel,inel);txel.addEventListener("input",parse);
try{
let inel=document.querySelector("input#formula");let txel=document.createElement("textarea");txel.setAttribute("id","formula");txel.value=inel.value;txel.style.fontFamily="monospace";inel.parentNode.replaceChild(txel,inel);txel.addEventListener("input",parse);
} catch (e){
let tx=(e.stack?e.stack:(e.toString?e.toString():(e+"")));tx=(tx?tx:"(unknown)");alert("An error has occured. Here are common possible reasons why this happens:\n- Input element was already replaced by textarea\n- Input element can't be found\n- Code was fed directly into the input (this was designed to be ran with JSArt Browser)\n\nTechnical Information:\n"+tx);
}
window.brws.currentDemo="";
})();

0 comments on commit 2178f6f

Please sign in to comment.