Hi amoid! Thanks a lot for all your explanations and the json example. Yes, the decodeBase64() could frigthen a “little bit” beginners You’re right: if ones wants to make a real example of a registering and login page ones should use a service side script (JS, PHP) and a database on server side too. But that’s not my intention here because it could take for a very long time before a beginner learns all the necessary skills to be able to write such a project or even simply understand its code (client / server paradigm, database modeling, SQL, web application, …)
My idea is to make make simple code in order to simulate this registering and login process on client side only with p5.js and html. In this simulation, a simple array, list or json table saved into a file could simulate a database table.
The process would be the following:
- the user register with an html form
- the application gets the user data from the form fields
- the user data are added to a list or json table
- the list or table is saved into a file on client side
- the user goes to the login page and enter username and password into login form
- the application reads the file and import back the user data
- the application compares user password to validate or not the login
But of course, during the same session, we can pass over step #4 and #6. And as an alternative we can give the opportunity to user to download the table as a file in order to save it to the sketch folder (assets) if he doesn’t want to loose the data he entered. This would replace step #4 that would be done mannualy. And afterwards the step #6 could be possible for the login.
If saveStrings, saveJson, … functions could also works as symetric functions for loadStrings, loadJson, … it would great too. Because for beginners (and non beginners: I’ve been programming for more than 36 years…) the symetric names used for those functions are confusing concerning what they really do and their roles, leaving to think they have similar contracts.
We’re gonna start a definitely new cs course for the first time in all our highschool and there are very long discussions and even ‘struggle’ concerning the choice of programming languages. For some people, teachers should be able to choose the langage they want to use with their students, for others they should not and the language should be imposed and be the same for everyone, in the interest of students. Others arguments we should let the choice between two easy langages for beginners with close syntax: Python and Javascript. And even that it would be a chance for students to discover it exists differents langages and that it’s not so difficult to pass from one to another for the basic concepts (variables, loops, functions, etc) but that the main difference is that all languages does not provide the same libraries and there are some specialized to manipulate somes technologies and some for other technologies (typically web, roborts, etc).
The problem is that the mainstream idea today is still to impose one common language to all teachers. And most of people will vote for Python. It’s a very good language but mainly a ‘desktop’ language (of course it can be used on server side but for beginners it has no really interest). If Python is choosen and imposed, we can forget to use p5.js (a very creative one that could motivate our students because they live every hour in the world of the the web) in order to teach programming to our student.
So now we are trying to convince that the best way for everyone would be to accept both Javascript and Python in our courses. And we’re writting a comparison table showing how you write fundamentals (variables, loops, test, etc) in both languages to demonstrate that difference are so minors that it wouldn’t be serious a problem for a student having learnt fundamentals to pass from language to another if using same libraries, what can be the case with Processing (we could even extends our table to Java…) But when we compare Javascript and Python, ones could says that with Javascript it’s not possible to save locally data into a file and read it back afterwards, what is very easy with Python in dekstop application.
That’s one of the reason why I try to find a solution to enable a JS program to be able to do the same in an easy way and I hoped that saveStrings and loadStrings() could provide this way…