Posts

Showing posts from November, 2023

Dynamic HTML List

Dynamic HTML List Items and Anchors List Items Imagine this Javascript code where we call addRowToList() each time new data is read in: < script >   var lineCounter = 0 ;     function addRowToList () {     const list = document . getElementById ( "thelist" );     lineCounter ++;     list . innerHTML += `<li>Item ${ lineCounter } </li>` ;   } </ script >     Anchors  

React: Login pages with JSON Web Tokens

React: Login pages with JSON Web Tokens      I have finished Shaun Wassell's course on LinkedIn learning on the Authentication process using React and JSON Web Tokens. The course was excellent.  Other technologies and libraries he uses are Mongol DB (for NoSql database), Axios (for fetching), jsonwebtoken (for JWTs), Babel (for more compact syntax in JSX and backward comparability), bcrypt (for encryption), Express (for fetching), OAuth 2.0 connecting to Goggle, Amazon Cognito as an authentication alternative, NodeJs, and sendgrid (for email sending).      The course is over 5 hours long of instruction.  What is really good in the course is the OAuth 2.0, JSON Web Tokens, and Amazon Cognito sections.  What could be improved is his teaching style is hand-typing all the code (having the viewer wait as he types) and talking explaining as he goes.  He could just copy and paste sections and adjust them so that he focuses on explaini...

Javascript: JSON file reading

 Javascript: JSON file reading Assume the targetJsonFileUrl is declared for the options below:     const targetJsonFileUrl = 'http://myServer.com/data.json'; Options:     1) Fetch command * preferred * fetch(proxyUrl + targetJsonFileUrl)   .then(response => response.json())   .then(data => console.log(data))   .catch(error => console.error('Error:', error));      2) Stringify and Parse statement var object = JSON.stringify(document.activeElement.textContent.replaceAll('\n','')); var json = JSON.parse(JSON.parse(object)); then access data that is in the json object: json.items[0].contactInfo.firstName      3) Import statement import data from targetJsonFileUrl assert { type: 'json' }; The challenge is CORS errors (Cross Origin Request).  CORS errors are usually not a problem when we are fetching data from a server.  The best ways to deal with CORS errors are:    1) Have a ...

Javascript: What JS IDEs Could Learn From Delphi

Image
What Javascript Code Editors  Could Learn From Delphi    The Delphi compiler has been around for a long time (1995, so 28 years) and produces a potentially object-oriented Pascal language code.  Delphi was at the fore front of Rapid Application Design.  Visual Programming that influenced Microsoft's Visual Studio's WinForms (Visual Basic and C#).  Anders Hejlsberg is still the head of Microsoft's C# team and was the chief architect of Borland's Turbo Pascal and Delphi compiler team .  At the moment in 2023, Delphi v12 is out as a paid version and Delphi v11 is the free community version.      The core thing that Javascript code editors could learn from Delphi is how to visually drag-and-drop the controls in a WYSIWYG fashion to the main screen.   For this example, we will assume that the developer wants to create a customer detail screen with a customer name field and a button.  So working on a Delphi screen works like this....