Sunday, July 25, 2010

Doing form saving with web worker

The Web worker and form field saving, it seems to work. The only problem is that the Web Worker cannot access DOM. I have tried localstorage as well. It cannot retrieve the form field values. This is what I did:

1) User clicks save
2) Increase the queue number
3) Pass the job to the web worker
4) After the webworker done saving with the item, decrease queue and increase completed

In this prototype, however, I hard coded the text variable, that actually should receive the value from a textarea of a form, because I cannot find a solution to pass the value to the web worker. On the other hand, the result was almost there - the queue and completed can increase and decrease based on the web worker. The number of saves clicked and the record number in the database are equals. There is no lags even when the user made quick clicks.

Without the web worker (AJAX only) user can click as many times as he wants, but there will be a lag. Nevertheless, the number of records in database and clicks are equals.

Some how it proved the concept, but it might not necessarily work. Another alternative will be to use the web worker as a queue manager.

numly esn 75682-100725-673958-46


© 2010 All Rights Reserved.

Wednesday, July 21, 2010

I am back!

My GOSH! It has been 8 months since I last posted here! I have even forgotten the URL for this blog! Good think I have this linked to another site! Well, thinking of re-activating my blogging habit coz I have so much to do with new tech all around, and plenty of other things going on around! Hopefully this blog can serve as a reminder and 'notes' on the new things I am going to discover!

After a training in my office on HTML5, I am quite fascinated by the cool stuff that has become available in wed development. One of the things that keeps ringing in my mind is the Web worker. It is very useful for websites that does multiple things at the same time. One of the things that I have in mind with this Web worker is background saving.

The idea behind it comes to solve one of the major disadvantages of the network in this country - slow and unstable. Work can become less efficient, waiting for the message "Your record has been saved."! The initial concept, as I viewed it is this:

1) User fills form
2) User saves form
3) A child window will be opened, where the Web worker does the saving at the background while user enters new data in a new form in the parent window
4) Upon saving the new batch of data, it will be queued up for the Web worker, displayed in the child window
5) When the the saving for the first item in the queue has been completed, the Web worker will process the next batch of data
6) For each item in the queue, a success/ failure message will be displayed to the user
7) If the saving has failed, a link will be displayed and user can click on it to return to the form with the data and the message, for correction.
8) If all saving were successful, user may close the child window.
9) If the user has accidentally closed all the windows, the data in the queue will be saved as a storage to the client PC (another HTML5 feature) so that when the user re-visits the website, Web worker can continue the saving work.

Of course, there are a lot of details that needs to be looked into. However, this is my initial idea, based on what I already know at the moment. A lot still need to be researched and discovered... and this is a good chance to keep my blog updated. If any of my dear readers has any good opinion, feel free to comment. Thanks!

numly esn 36929-100721-286431-70


© 2010 All Rights Reserved.