Thursday, December 30, 2010

IE9'S INDEXEDDB PROTOTYPE IMPLEMENTATION

WIth HTML5 Labs we HTML5 prototype implementations. I have me the implementation IndexedDB viewed. First you have to ask yourself how you can expand the JavaScript functionality of Internet Explorer? The answer is: Component Object Model or COM shortly.

Installation
The implementation comes with two COM objects, therefore, the use under the hood of the SQL Server Compact 4th Once with a synchronous interface and the asynchronous version. The installation of the prototype is easy. First, you download the package, then to register dll in a command window elevates the appropriate COM using regsvr32.

 regsvr32 sqlcejse40.dll

After registering, you have the privileged IE9 but also start to work with the prototype.
It always requires a initialization. Finally, the functionality in the COM component is inside and we would all use of JavaScript. The package comes with such a script and called bootidb.js. A look into the appropriate line of code tells us also the window element according to a property indexedDB is added to the:
 1: if (! Window.indexedDB) {
 2: window.indexedDB = new ActiveXObject ("SQLCE.Factory.4.0");
 3: window.indexedDBSync = new ActiveXObject ("SQLCE.FactorySync.4.0");

What I never was so aware of the possibility of any viable IDispatch object in the HTML DOM to plug the browser. Looking at times that is the type library of COM objects we see the methods which we finally used directly from JavaScript:

  1: [
  2:   odl,
  3:   uuid(567270C8-E61A-4A8D-9C2E-2D2EC47D8704),
  4:   helpstring("ObjectStore - Asynchronous interface"),
  5:   dual,
  6:   nonextensible,
  7:   oleautomation
  8: ]
  9: interface IDBObjectStoreRequest : IDBObjectStore {
 10:     [id(0x60040000)]
 11:     HRESULT put(
 12:                     [in] VARIANT value,
 13:                     [in, optional] VARIANT key,
 14:                     [out, retval] IDBRequest** ppWebRequest);
 15:     [id(0x60040001)]
 16:     HRESULT add(
 17:                     [in] VARIANT value,
 18:                     [in, optional] VARIANT key,
 19:                     [out, retval] IDBRequest** ppWebRequest);
 20:     [id(0x60040002)]
 21:     HRESULT get(
 22:                     [in] VARIANT key,
 23:                     [out, retval] IDBRequest** ppWebRequest);
 24:     [id(0x60040003)]
 25:     HRESULT remove(
 26:                     [in] VARIANT key,
 27:                     [out, retval] IDBRequest** ppWebRequest);
 28:     [id(0x60040004)]
 29:     HRESULT createIndex(
 30:                     [in] BSTR name,
 31:                     [in] BSTR keyPath,
 32:                     [in, optional] VARIANT unique,
 33:                     [out, retval] IDBRequest** ppWebRequest);
 34:     [id(0x60040005)]
 35:     HRESULT index(
 36:                     [in] BSTR indexName,
 37:                     [out, retval] IDBRequest** ppWebRequest);

Read more: Dariusz quatscht (original in German)
Read more: Dariusz quatscht (translated to English)